public void TestPublishWithDefaultLocation() { using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService cloudServiceProject = new AzureService(rootPath, null); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); serviceManagementChannelMock.Setup(f => f.EndListLocations(It.IsAny <IAsyncResult>())) .Returns(new LocationList() { new Location() { Name = "East US" } }); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService()); serviceManagementChannelMock.Verify(f => f.BeginListLocations( subscription.SubscriptionId, null, null), Times.Once()); } }
public void EnableRemoteDesktop() { Validate.ValidateStringIsNullOrEmpty(Username, "Username"); if (Password == null) { throw new ArgumentNullException("Password"); } string plainPassword = GetPlainPassword(); if (!IsPasswordComplex(plainPassword)) { throw new ArgumentException(Properties.Resources.EnableAzureRemoteDesktopCommand_Enable_NeedComplexPassword); } AzureService service = new AzureService(GetServiceRootPath(), null); WebRole[] webRoles = service.Components.Definition.WebRole ?? new WebRole[0]; WorkerRole[] workerRoles = service.Components.Definition.WorkerRole ?? new WorkerRole[0]; string forwarderName = GetForwarderName(webRoles, workerRoles); RemoveOtherRemoteForwarders(webRoles, workerRoles, forwarderName); AddRemoteAccess(webRoles, workerRoles); X509Certificate2 cert = ChooseCertificate(); ServiceConfigurationSchema.Certificate certElement = new ServiceConfigurationSchema.Certificate { name = "Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption", thumbprintAlgorithm = ThumbprintAlgorithmTypes.sha1, thumbprint = cert.Thumbprint }; string encryptedPassword = Encrypt(plainPassword, cert); UpdateServiceConfigurations(service, forwarderName, certElement, encryptedPassword); service.Components.Save(service.Paths); }
public void SetDeploymentStatusProcessDeploymentDoesNotExistTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Running; string resultMessage; string expectedMessage = string.Format(Resources.ServiceSlotDoesNotExist, serviceName, slot); bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => { throw new EndpointNotFoundException(); }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var deploymentManager = new DeploymentStatusManager(channel); deploymentManager.ShareChannel = true; resultMessage = deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); Assert.IsFalse(statusUpdated); Assert.AreEqual<string>(expectedMessage, resultMessage); } }
/// <summary> /// Retrieve the runtimes from the given manifest, or from the default cloud location, if none given. /// The manifest parameter is mainly a testing hook. /// </summary> /// <param name="runtimeType">The runtime type to filter by</param> /// <param name="rootPath">The path to the service in question</param> /// <param name="manifest">The path to the manifest file, if null, the default cloud manifest is used (test hook)</param> public void GetAzureRuntimesProcess(string runtimeType, string rootPath, string manifest = null) { AzureService service = new AzureService(rootPath, null); CloudRuntimeCollection runtimes = service.GetCloudRuntimes(service.Paths, manifest); WriteObject(runtimes.Where<CloudRuntimePackage>(p => string.IsNullOrEmpty(runtimeType) || p.Runtime == CloudRuntime.GetRuntimeByType(runtimeType)), true); }
public void SetDeploymentStatusProcessDeploymentDoesNotExistTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Running; string resultMessage; string expectedMessage = string.Format(Resources.ServiceSlotDoesNotExist, serviceName, slot); bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => { throw new EndpointNotFoundException(); }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); resultMessage = new DeploymentStatusManager(channel).SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); Assert.IsFalse(statusUpdated); Assert.AreEqual <string>(expectedMessage, resultMessage); } }
public UploadProcessor(string containerName, string accountName, string accountKey) { this.containerName = containerName; azureService = new AzureService(accountName, accountKey); queue = new ConcurrentQueue <Tuple <String, String> >(); running = true; }
public void EnableRemoteDesktopForWebAndWorkerRoles() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole", Instances = 1 }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole", Instances = 1 }; addNodeWorkerCmdlet.ExecuteCmdlet(); mockCommandRuntime.ResetPipelines(); EnableRemoteDesktop("user", "GoodPassword!"); // Verify the roles have been setup with forwarding, access, // and certs AzureService service = new AzureService(rootPath, null); VerifyWebRole(service.Components.Definition.WebRole[0], false); VerifyWorkerRole(service.Components.Definition.WorkerRole[0], true); VerifyRoleSettings(service); Assert.AreEqual <int>(0, mockCommandRuntime.OutputPipeline.Count); } }
public LoginViewModel(IAzureService azureService, Page page) { _azureService = azureService as AzureService; _page = page; LoginCommand = new Command(ExecuteLoginCommand); }
//--------------------------------------------------CONSTRUTOR-------------------------------------------------// public MenuPageViewModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService, pageDialogService) { loginService = new AzureService(); azureService = Xamarin.Forms.DependencyService.Get <AzureService>(); LoginFacebookCommand = new DelegateCommand(async() => await ExecuteLoginFacebookCommand()); LogOutFacebookCommand = new DelegateCommand(async() => await ExecuteLogOutFacebookCommandAsync()); SchedulesWeekPageCommand = new DelegateCommand(async() => await ExecuteSchedulesWeekPageCommand()); MainPageCommand = new DelegateCommand(async() => await ExecuteMainPageCommand()); EditServicesCommand = new DelegateCommand(async() => await ExecuteEditServicesCommand()); if (Settings.IsLoggedIn) { GetNameAsync(); } else { Privilegio = "Faça o login"; } if (!CrossConnectivity.Current.IsConnected) { Settings.AuthToken = string.Empty; Settings.UserId = string.Empty; } IsVisibleAdminButtons = Settings.IsAdmin; IsVisibleLogInButton = !Settings.IsLoggedIn; IsVisibleLogOutButton = Settings.IsLoggedIn; IsVisibleMainPageButton = false; }
public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = "GetStopwatch")] HttpRequestMessage req, TraceWriter log) { var configuration = new HttpConfiguration(); req.Properties[System.Web.Http.Hosting.HttpPropertyKeys.HttpConfigurationKey] = configuration; var data = await req.Content.ReadAsStringAsync(); var requestBody = JsonConvert.DeserializeObject <UserDetailsEntity>(data); if (string.IsNullOrEmpty(requestBody.UserName) && string.IsNullOrEmpty(requestBody.StopWatchName)) { return(req.CreateResponse(HttpStatusCode.BadRequest, "Please pass a username and/or stopwatchname on the query string or in the request body")); } IAzureService azureService = new AzureService(); IStopwatchDetails stopwatchDetails = new StopwatchDetails(azureService); var stopwatchStatus = new GetStatus(stopwatchDetails); var userDetails = JsonConvert.SerializeObject(await stopwatchStatus.RetrieveElapsedTime(requestBody)); //If webjob is running change this to .Retrieve return(req.CreateResponse(HttpStatusCode.OK, userDetails)); }
public void RemoveAzureServiceProcessTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); bool serviceDeleted = false; bool deploymentDeleted = false; channel.GetDeploymentBySlotThunk = ar => { if (deploymentDeleted) { throw new EndpointNotFoundException(); } return(new Deployment(serviceName, ArgumentConstants.Slots[Slot.Production], DeploymentStatus.Suspended)); }; channel.DeleteHostedServiceThunk = ar => serviceDeleted = true; channel.DeleteDeploymentBySlotThunk = ar => { deploymentDeleted = true; }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var removeAzureServiceCommand = new RemoveAzureServiceCommand(channel); removeAzureServiceCommand.ShareChannel = true; removeAzureServiceCommand.RemoveAzureServiceProcess(service.Paths.RootPath, string.Empty, serviceName); Assert.IsTrue(deploymentDeleted); Assert.IsTrue(serviceDeleted); } }
public void RemoveAzureServiceProcessTest() { bool serviceDeleted = false; bool deploymentDeleted = false; channel.GetDeploymentBySlotThunk = ar => { if (deploymentDeleted) throw new EndpointNotFoundException(); return new Deployment(serviceName, ArgumentConstants.Slots[Slot.Production], DeploymentStatus.Suspended); }; channel.DeleteHostedServiceThunk = ar => serviceDeleted = true; channel.DeleteDeploymentBySlotThunk = ar => { deploymentDeleted = true; }; channel.IsDNSAvailableThunk = ida => new AvailabilityResponse { Result = false }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); removeServiceCmdlet.PassThru = true; removeServiceCmdlet.RemoveAzureServiceProcess(service.Paths.RootPath, string.Empty, serviceName); Assert.IsTrue(deploymentDeleted); Assert.IsTrue(serviceDeleted); Assert.IsTrue((bool)mockCommandRuntime.OutputPipeline[0]); } }
/// <summary> /// Factory method to apply memcache required configuration based on the installed SDK version. /// </summary> /// <param name="azureService">The azure service instance</param> /// <param name="webRole">The web role to enable caching on</param> /// <param name="isWebRole">Flag indicating if the provided role is web or not</param> /// <param name="cacheWorkerRole">The memcache worker role name</param> /// <param name="startup">The role startup</param> /// <param name="endpoints">The role endpoints</param> /// <param name="localResources">The role local resources</param> /// <param name="configurationSettings">The role configuration settings</param> /// <param name="sdkVersion">The current SDK version</param> private void CachingConfigurationFactoryMethod( AzureService azureService, string roleName, bool isWebRole, string cacheWorkerRole, Startup startup, Endpoints endpoints, LocalResources localResources, ref DefinitionConfigurationSetting[] configurationSettings, string sdkVersion) { switch (sdkVersion) { case SDKVersion.Version180: Version180Configuration( azureService, roleName, isWebRole, cacheWorkerRole, startup, endpoints, localResources, ref configurationSettings); break; default: throw new Exception(string.Format(Resources.AzureSdkVersionNotSupported, Resources.MinSupportAzureSdkVersion, Resources.MaxSupportAzureSdkVersion)); } }
public void TestUpgradeCloudService() { using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService cloudServiceProject = new AzureService(rootPath, null); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); cloudService.Deployments.Add(deployment); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US")); serviceManagementChannelMock.Verify(f => f.BeginUpgradeDeploymentBySlot( subscription.SubscriptionId, serviceName, DeploymentSlotType.Production, It.IsAny <UpgradeDeploymentInput>(), null, null), Times.Once()); } }
public void TestCreateStorageServiceWithPublish() { using (FileSystemHelper files = new FileSystemHelper(this) { EnableMonitoring = true }) { // Setup string rootPath = files.CreateNewService(serviceName); files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService cloudServiceProject = new AzureService(rootPath, null); cloudServiceProject.AddWebRole(Data.NodeWebRoleScaffoldingPath); cloudService.Deployments.Add(deployment); serviceManagementChannelMock.Setup(f => f.EndGetStorageService(It.IsAny <IAsyncResult>())) .Callback(() => serviceManagementChannelMock.Setup(f => f.EndGetStorageService( It.IsAny <IAsyncResult>())) .Returns(storageService)) .Throws(new EndpointNotFoundException()); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US")); serviceManagementChannelMock.Verify(f => f.BeginCreateStorageService( subscription.SubscriptionId, It.IsAny <CreateStorageServiceInput>(), null, null), Times.Once()); } }
public async Task <IActionResult> Post(string task_id, int id, [FromBody] string value) { var userId = HttpContext.User.Identity.Name; bool re = await AzureService.FindUserHasThisTask(userId, HttpContext.Session, task_id); if (re) { var blob = AzureService.GetBlob(null, $"tasks/{task_id}/images", $"{id}.json"); try { var json = JsonConvert.DeserializeObject <JObject>(Base64Ops.Base64Decode(value)); await AzureService.UpdateTaskStatusToBlob(task_id, id, userId, "commit"); await blob.UploadGenericObjectAsync(json); } catch (Exception e) { return(Content(new Response { Successful = "false", Msg = e.Message, Data = null }.JObjectToString())); } } return(Content(new Response { Successful = "true", Msg = "ok", Data = null }.JObjectToString())); }
//1st method // async Task ExecuteLoadCoffeesCommandAsync() public async void ExecuteLoadCoffeesCommandAsync() { azureService = new AzureService(); string enteredEmail = email.Text; string enteredPassword = pass.Text; bool login = false; string Name; try { login = await azureService.GetCoffee(enteredEmail, enteredPassword); Name = await azureService.GetUserName(enteredEmail, enteredPassword); UserName.Add(Name); if (login == true) { UserEmail.Add(enteredEmail); await Navigation.PushAsync(new MenuPage(Name)); pass.Text = ""; } if (login == false) { await DisplayAlert("Alert", "Email and/or Password is incorrect", "ok"); } } catch (Exception ex) { Debug.WriteLine("OH NO! " + ex); } }
public async Task <List <Cat> > GetCats() { var Service = new AzureService <Cat>(); var Items = await Service.GetTable(); return(Items.ToList()); }
private static async Task <string> GetConnectionStringImagesStorage(IConfiguration configuration) { var imagesStorageSecretName = configuration["Azure:KeyVault:ImagesStorageSecretName"]; var azure = new AzureService(); return(await azure.GetKeyVaultSecretAsync(imagesStorageSecretName)); }
protected override void OnInitialized() { try { InitializeComponent(); MobileService = DependencyService.Get <AzureService>(); MobileService.Initialize(); ApiService = RestService.For <IApiService>(ApplicationParameters.ApiUrl); if (!Settings.IsLoggedIn) { NavigationService.NavigateAsync($"NavigationPage/{nameof(LoginPage)}"); } else { NavigationService.NavigateAsync($"{nameof(MenuPage)}/NavigationPage/{nameof(LoadingPostersPage)}"); } } catch (Exception ex) { Debug.WriteLine(ex.StackTrace); } }
public LoginHandlePage(bool tlLogin) { InitializeComponent(); azureService = DependencyService.Get <AzureService>(); teamLeader = tlLogin; SetupLabel(); }
private void UpdateServiceConfigurations(AzureService service, string forwarderName) { foreach (ServiceConfiguration config in new[] { service.Components.LocalConfig, service.Components.CloudConfig }) { foreach (RoleSettings role in config.Role) { if (role.ConfigurationSettings != null) { ConfigurationSetting setting = role.ConfigurationSettings. FirstOrDefault <ConfigurationSetting>(t => t.name.Equals( "Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled")); if (setting != null) { setting.value = "false"; } if (role.name == forwarderName) { ConfigurationSetting forwarderSetting = role.ConfigurationSettings. FirstOrDefault <ConfigurationSetting>(t => t.name.Equals( "Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled")); if (forwarderSetting != null) { forwarderSetting.value = "false"; } } } } } }
public void SetDeploymentStatusProcessDeploymentDoesNotExistTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Running; string resultMessage; string expectedMessage = string.Format(Resources.ServiceSlotDoesNotExist, slot, serviceName); bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment{Name = serviceName, DeploymentSlot = slot, Status = newStatus}; }; channel.GetDeploymentBySlotThunk = ar => { throw new ServiceManagementClientException(HttpStatusCode.NotFound, new ServiceManagementError(), string.Empty); }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var deploymentManager = new DeploymentStatusManager(channel); deploymentManager.ShareChannel = true; deploymentManager.CommandRuntime = new MockCommandRuntime(); deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName); resultMessage = ((MockCommandRuntime)deploymentManager.CommandRuntime).WarningStream[0]; Assert.IsFalse(statusUpdated); Assert.IsTrue(resultMessage.Contains(expectedMessage)); Assert.IsTrue(((MockCommandRuntime)deploymentManager.CommandRuntime).OutputPipeline.Count.Equals(0)); } }
/// <summary> /// Configure the worker role for caching by: /// * Add caching module to the role imports. /// * Enable caching Diagnostic store. /// * Remove input endpoints. /// * Add caching configuration settings. /// </summary> /// <param name="rootPath"></param> /// <param name="cacheRoleInfo"></param> /// <returns></returns> private AzureService Version180Configuration(string rootPath, RoleInfo cacheRoleInfo) { // Fetch cache role information from service definition and service configuration files. AzureService azureService = new AzureService(rootPath, null); WorkerRole cacheWorkerRole = azureService.Components.GetWorkerRole(cacheRoleInfo.Name); RoleSettings cacheRoleSettings = azureService.Components.GetCloudConfigRole(cacheRoleInfo.Name); // Add caching module to the role imports cacheWorkerRole.Imports = General.ExtendArray <Import>(cacheWorkerRole.Imports, new Import { moduleName = Resources.CachingModuleName }); // Enable caching Diagnostic store. LocalStore diagnosticStore = new LocalStore { name = Resources.CacheDiagnosticStoreName, cleanOnRoleRecycle = false }; cacheWorkerRole.LocalResources = General.InitializeIfNull <LocalResources>(cacheWorkerRole.LocalResources); cacheWorkerRole.LocalResources.LocalStorage = General.ExtendArray <LocalStore>(cacheWorkerRole.LocalResources.LocalStorage, diagnosticStore); // Remove input endpoints. cacheWorkerRole.Endpoints.InputEndpoint = null; // Add caching configuration settings AddCacheConfiguration(azureService.Components.GetCloudConfigRole(cacheRoleInfo.Name)); AddCacheConfiguration(azureService.Components.GetLocalConfigRole(cacheRoleInfo.Name), Resources.EmulatorConnectionString); return(azureService); }
public async Task Start() { var entries = database.GetItemsNotDone().ToList(); int itemCount, totalItems; itemCount = totalItems = entries.Count; foreach (var item in entries) { if (!shouldUpload) { UploadButtonEnabled = true; return; } StatusMessage = string.Format("Remaining Items {0} / {1}", itemCount, totalItems); var result = await AzureService.UploadTrainingMedia(item); if (result) { database.DeleteItem(item); itemCount--; } else { StopUploadCommand.Execute(null); } } }
public MapPageViewModel(INavigationService navigationService) { azureService = DependencyService.Get <AzureService>(); _navigationService = navigationService; OnMapLoadCommand = new DelegateCommand <CustomMap>(async(param) => await LoadMap(param)); OnTrackingCommand = new DelegateCommand <CustomMap>(async(param) => await LoadPetPositions(param)); }
// constructor public CourseViewModel() { azureService = DependencyService.Get <AzureService>(); // implement the ICommands SelectionCommand = new Command <Course>(async(item) => { if (item == null) { return; } IsBusy = true; Debug.WriteLine(string.Concat("Course selected is: ", item.CourseName)); await Shell.Current.Navigation.PushAsync(new CourseDetailPage(item)); // un-select the list Selection = null; IsBusy = false; }); AddCommand = new Command(async() => { // create new course object with a guid id and pass to page Course course = new Course(); course.CourseId = Guid.NewGuid().ToString(); IsBusy = true; Debug.WriteLine("Add course screen... "); await Shell.Current.Navigation.PushAsync(new CourseDetailPage(course)); IsBusy = false; }); // subscribe to messaging so that updates in detail ViewModel can reflect back in the list SubscribeToMessageCenter(); }
public async Task <IActionResult> Token() { var userId = await AzureService.FindUserId(await _userManager.GetUserAsync(HttpContext.User)); if (userId == null) { return(Redirect("/Identity/Account/Manage")); } var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(_configuration["SecurityKey"])); var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256); var claims = new[] { new Claim(ClaimTypes.Name, userId) }; var token = new JwtSecurityToken( issuer: "apulis-china-infra01.sigsus.cn", audience: "apulis-china-infra01.sigsus.cn", claims: claims, expires: DateTime.Now.AddDays(1), signingCredentials: creds); var tokenGenerate = new JwtSecurityTokenHandler().WriteToken(token); return(Redirect($"{_configuration["FontEndUrl"]}/?token={tokenGenerate}")); }
public TarefaViewModel() { AddCommand = new Command(ExecuteAddCommand); CarregaCommand = new Command(ExecuteCarregaCommand); Tarefas = new ObservableCollection <Tarefa>(); Servico = new AzureService <Tarefa>(); }
public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "hunts/list/")] HttpRequest req, ILogger log) { var azureService = new AzureService(); try { var rows = await azureService.executeCommand($"SELECT * FROM Hunts;", "HuntMo"); if (rows != null) { var res = JsonConvert.SerializeObject(rows); return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(res, Encoding.UTF8, "application/json") }); } else { return(new HttpResponseMessage(HttpStatusCode.BadRequest) { Content = new StringContent("Could not find Hunts", Encoding.UTF8, "application/json") }); } } catch { return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); } }
public void SetDeploymentStatusProcessSetStatusToActualStatusTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Suspended; string currentStatus = DeploymentStatus.Suspended; string resultMessage; string expectedMessage = string.Format(Resources.DeploymentAlreadyInState, slot, serviceName, currentStatus); bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => new Deployment(serviceName, slot, currentStatus); using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var deploymentManager = new DeploymentStatusManager(channel); deploymentManager.ShareChannel = true; resultMessage = deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); Assert.IsFalse(statusUpdated); Assert.AreEqual <string>(expectedMessage, resultMessage); } }
public async Task <IActionResult> Get() { var userId = HttpContext.User.Identity.Name; var tasks = await AzureService.FindUserTasks(userId, HttpContext.Session); return(Content(Base64Ops.Base64Encode(tasks.JObjectToString()))); }
public void SetDeploymentStatusProcessTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Suspended; string currentStatus = DeploymentStatus.Running; bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => new Deployment(serviceName, slot, currentStatus); using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var deploymentManager = new DeploymentStatusManager(channel); deploymentManager.ShareChannel = true; deploymentManager.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); Assert.IsTrue(statusUpdated); } }
public static async Task <HttpResponseMessage> Run( [HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "clues/")] HttpRequest req, ILogger log) { string clueQuery = req.Query["clueid"]; string requestBody = await new StreamReader(req.Body).ReadToEndAsync(); dynamic data = JsonConvert.DeserializeObject(requestBody); var clueid = clueQuery ?? data?.clueid; var azureService = new AzureService(); try { var rows = await azureService.executeCommand($"SELECT * FROM Clues WHERE ClueId = '{clueid}';", "ClueMo"); if (rows != null) { var res = JsonConvert.SerializeObject(rows); return(new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(res, Encoding.UTF8, "application/json") }); } } catch { return(new HttpResponseMessage(HttpStatusCode.BadRequest)); } return(new HttpResponseMessage(HttpStatusCode.InternalServerError)); }
public AzureService StartAzureEmulatorProcess(string rootPath) { string standardOutput; string standardError; StringBuilder message = new StringBuilder(); AzureService service = new AzureService(rootPath ,null); if (Directory.Exists(service.Paths.LocalPackage)) { WriteVerbose(string.Format(Resources.RemovePackage, service.Paths.LocalPackage)); Directory.Delete(service.Paths.LocalPackage, true); } WriteVerbose(string.Format(Resources.CreatingPackageMessage, "local")); service.CreatePackage(DevEnv.Local, out standardOutput, out standardError); WriteVerbose(Resources.StartingEmulator); service.StartEmulator(Launch.ToBool(), out standardOutput, out standardError); WriteVerbose(standardOutput); WriteVerbose(Resources.StartedEmulator); SafeWriteOutputPSObject( service.GetType().FullName, Parameters.ServiceName, service.ServiceName, Parameters.RootPath, service.Paths.RootPath); return service; }
public ReportsViewModel() { azureService = DependencyService.Get <AzureService>(); Title = "Reports"; // Results command ResultsCommand = new Command(async() => { IsBusy = true; if (SelectedCompetition != null) { // create new society object Competition item = SelectedCompetition; await Shell.Current.Navigation.PushAsync(new ResultsPage(item)); } IsBusy = false; }); // Results command DiscardsCommand = new Command(async() => { IsBusy = true; if (SelectedCompetition != null) { // create new society object Competition item = SelectedCompetition; await Shell.Current.Navigation.PushAsync(new DiscardPage(item)); } IsBusy = false; }); }
public void GetNextPortAllNull() { using (FileSystemHelper files = new FileSystemHelper(this)) { int expectedPort = int.Parse(Resources.DefaultWebPort); AzureService service = new AzureService(files.RootPath, serviceName, null); int nextPort = service.Components.GetNextPort(); Assert.AreEqual<int>(expectedPort, nextPort); } }
public string StopAzureEmulatorProcess() { string standardOutput; string standardError; AzureService service = new AzureService(); SafeWriteObject(Resources.StopEmulatorMessage); service.StopEmulator(out standardOutput, out standardError); SafeWriteObject(Resources.StoppedEmulatorMessage); return null; }
public void GetNextPortNodeWebRoleNull() { using (FileSystemHelper files = new FileSystemHelper(this)) { int expectedPort = int.Parse(Resources.DefaultPort); AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath); service = new AzureService(service.Paths.RootPath, null); int nextPort = service.Components.GetNextPort(); Assert.AreEqual<int>(expectedPort, nextPort); } }
public void DisableRemoteDesktop() { AzureService service = new AzureService(GetServiceRootPath(), null); WebRole[] webRoles = service.Components.Definition.WebRole ?? new WebRole[0]; WorkerRole[] workerRoles = service.Components.Definition.WorkerRole ?? new WorkerRole[0]; string forwarderName = GetForwarderName(webRoles, workerRoles); if (forwarderName != null) { UpdateServiceConfigurations(service, forwarderName); service.Components.Save(service.Paths); } }
public void GetNextPortAddingThirdEndpoint() { using (FileSystemHelper files = new FileSystemHelper(this)) { int expectedPort = int.Parse(Resources.DefaultPort) + 1; AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWebRole(Resources.NodeScaffolding); service.AddWebRole(Resources.PHPScaffolding); service = new AzureServiceWrapper(service.Paths.RootPath, null); int nextPort = service.Components.GetNextPort(); Assert.AreEqual<int>(expectedPort, nextPort); } }
public void CreateLocalPackageWithNodeWorkerRoleTest() { using (FileSystemHelper files = new FileSystemHelper(this)) { string standardOutput; string standardError; AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath); service.CreatePackage(DevEnv.Local, out standardOutput, out standardError); AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WorkerRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WorkerRole)); } }
internal string NewAzureServiceProcess(string parentDirectory, string serviceName) { string message; AzureService newService; // Create scaffolding structure // newService = new AzureService(parentDirectory, serviceName, null); message = string.Format(Resources.NewServiceCreatedMessage, newService.Paths.RootPath); return message; }
public string StartAzureEmulatorProcess(string rootPath) { string standardOutput; string standardError; StringBuilder message = new StringBuilder(); AzureService service = new AzureService(rootPath ,null); SafeWriteObject(string.Format(Resources.CreatingPackageMessage, "local")); service.CreatePackage(DevEnv.Local, out standardOutput, out standardError); SafeWriteObject(Resources.StartingEmulator); service.StartEmulator(Launch.ToBool(), out standardOutput, out standardError); SafeWriteObject(standardOutput); SafeWriteObject(Resources.StartedEmulator); return message.ToString(); }
public void StopAzureEmulatorProcess() { string standardOutput; string standardError; AzureService service = new AzureService(); WriteVerbose(Resources.StopEmulatorMessage); service.StopEmulator(out standardOutput, out standardError); WriteVerbose(Resources.StoppedEmulatorMessage); if (PassThru.IsPresent) { WriteObject(true); } }
internal AzureService NewAzureServiceProcess(string parentDirectory, string serviceName) { // Create scaffolding structure // AzureService newService = new AzureService(parentDirectory, serviceName, null); SafeWriteOutputPSObject( newService.GetType().FullName, Parameters.ServiceName, newService.ServiceName, Parameters.RootPath, newService.Paths.RootPath ); WriteVerbose(string.Format(Resources.NewServiceCreatedMessage, newService.Paths.RootPath)); return newService; }
internal string AddAzureDjangoWebRoleProcess(string webRoleName, int instances, string rootPath) { string result; AzureService service = new AzureService(rootPath, null); RoleInfo webRole = service.AddDjangoWebRole(webRoleName, instances); // let Django create it's scaffolding var interpPath = FindPythonInterpreterPath(); if (interpPath != null) { string stdOut, stdErr; Environment.CurrentDirectory = Path.Combine(rootPath, webRole.Name); ProcessHelper.StartAndWaitForProcess( new ProcessStartInfo( Path.Combine(interpPath, PythonInterpreterExe), String.Format(DjangoStartProjectCommand, webRole.Name) ), out stdOut, out stdErr ); if (!string.IsNullOrEmpty(stdErr)) { SafeWriteObject(String.Format(Resources.UnableToCreateDjangoApp, stdErr)); SafeWriteObject(Resources.UnableToCreateDjangoAppFix); } } else { SafeWriteObject(Resources.MissingPythonPreReq); } try { service.ChangeRolePermissions(webRole); } catch (UnauthorizedAccessException) { SafeWriteObject(Resources.AddRoleMessageInsufficientPermissions); SafeWriteObject(Environment.NewLine); } result = string.Format(Resources.AddRoleMessageCreatePython, rootPath, webRole.Name); return result; }
internal string AddAzurePHPWebRoleProcess(string webRoleName, int instances, string rootPath) { string result; AzureService service = new AzureService(rootPath, null); RoleInfo webRole = service.AddWebRole(Resources.PHPScaffolding, webRoleName, instances); try { service.ChangeRolePermissions(webRole); } catch (UnauthorizedAccessException) { SafeWriteObject(Resources.AddRoleMessageInsufficientPermissions); SafeWriteObject(Environment.NewLine); } result = string.Format(Resources.AddRoleMessageCreate, rootPath, webRole.Name); return result; }
public void DisableRemoteDesktop() { AzureService service = new AzureService(CloudServiceUtilities.GetServiceRootPath(CurrentPath()), null); WebRole[] webRoles = service.Components.Definition.WebRole ?? new WebRole[0]; WorkerRole[] workerRoles = service.Components.Definition.WorkerRole ?? new WorkerRole[0]; string forwarderName = GetForwarderName(webRoles, workerRoles); if (forwarderName != null) { UpdateServiceConfigurations(service, forwarderName); service.Components.Save(service.Paths); } if (PassThru) { WriteObject(true); } }
public void CreateLocalPackageWithOneNodeWebRoleTest() { using (FileSystemHelper files = new FileSystemHelper(this)) { string standardOutput; string standardError; AzureService service = new AzureService(files.RootPath, serviceName, null); RoleInfo webRoleInfo = service.AddWebRole(Data.NodeWebRoleScaffoldingPath); string logsDir = Path.Combine(service.Paths.RootPath, webRoleInfo.Name, "server.js.logs"); string logFile = Path.Combine(logsDir, "0.txt"); string targetLogsFile = Path.Combine(service.Paths.LocalPackage, "roles", webRoleInfo.Name, @"approot\server.js.logs\0.txt"); files.CreateDirectory(logsDir); files.CreateEmptyFile(logFile); service.CreatePackage(DevEnv.Local, out standardOutput, out standardError); AzureAssert.ScaffoldingExists(Path.Combine(service.Paths.LocalPackage, @"roles\WebRole1\approot"), Path.Combine(Resources.NodeScaffolding, Resources.WebRole)); Assert.IsTrue(File.Exists(targetLogsFile)); } }
public void TestCreatePackageSuccessfull() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); files.CreateNewService("NEW_SERVICE"); string rootPath = Path.Combine(files.RootPath, "NEW_SERVICE"); string packagePath = Path.Combine(rootPath, Resources.CloudPackageFileName); AzureService service = new AzureService(rootPath, null); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); cmdlet.ExecuteCmdlet(); PSObject obj = mockCommandRuntime.OutputPipeline[0] as PSObject; Assert.AreEqual<string>(string.Format(Resources.PackageCreated, packagePath), mockCommandRuntime.VerboseStream[0]); Assert.AreEqual<string>(packagePath, obj.GetVariableValue<string>(Parameters.PackagePath)); Assert.IsTrue(File.Exists(packagePath)); } }
public void SetDeploymentStatusProcessTest() { string newStatus = DeploymentStatus.Suspended; string currentStatus = DeploymentStatus.Running; bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => new Deployment(serviceName, slot, currentStatus); channel.IsDNSAvailableThunk = ida => new AvailabilityResponse { Result = false }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); stopServiceCmdlet.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName); Assert.IsTrue(statusUpdated); } }
public override void ExecuteCmdlet() { AzureTool.Validate(); string unused; string rootPath = General.GetServiceRootPath(CurrentPath()); string packagePath; AzureService service = new AzureService(rootPath, null); if (!Local.IsPresent) { service.CreatePackage(DevEnv.Cloud, out unused, out unused); packagePath = Path.Combine(rootPath, Resources.CloudPackageFileName); } else { service.CreatePackage(DevEnv.Local, out unused, out unused); packagePath = Path.Combine(rootPath, Resources.LocalPackageFileName); } WriteVerbose(string.Format(Resources.PackageCreated, packagePath)); SafeWriteOutputPSObject(typeof(PSObject).FullName, Parameters.PackagePath, packagePath); }
public void SetDeploymentStatusProcessTest() { SimpleServiceManagement channel = new SimpleServiceManagement(); string newStatus = DeploymentStatus.Running; string currentStatus = DeploymentStatus.Suspended; bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment(serviceName, slot, newStatus); }; channel.GetDeploymentBySlotThunk = ar => new Deployment(serviceName, slot, currentStatus); using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); var startAzureService = new StartAzureService(channel) { ShareChannel = true }; startAzureService.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionNames[0], serviceName); Assert.IsTrue(statusUpdated); } }
/// <summary> /// Main entry for enabling memcache. /// </summary> /// <param name="roleName">The web role name</param> /// <param name="cacheWorkerRoleName">The cache worker role name</param> /// <param name="rootPath">The service root path</param> /// <param name="message">The resulted message</param> /// <param name="azureService">The azure service instance</param> /// <param name="webRole">The web role to enable caching one</param> private void EnableMemcache(string roleName, string cacheWorkerRoleName, ref string message, ref AzureService azureService) { // Add MemcacheShim runtime installation. azureService.AddRoleRuntime(azureService.Paths, roleName, Resources.CacheRuntimeValue, CacheRuntimeVersion); // Fetch web role information. Startup startup = azureService.Components.GetRoleStartup(roleName); // Assert that cache runtime is added to the runtime startup. Debug.Assert(Array.Exists<Variable>(CloudRuntime.GetRuntimeStartupTask(startup).Environment, v => v.name.Equals(Resources.RuntimeTypeKey) && v.value.Contains(Resources.CacheRuntimeValue))); if (azureService.Components.IsWebRole(roleName)) { WebRole webRole = azureService.Components.GetWebRole(roleName); webRole.LocalResources = CloudServiceUtilities.InitializeIfNull<LocalResources>(webRole.LocalResources); DefConfigurationSetting[] configurationSettings = webRole.ConfigurationSettings; CachingConfigurationFactoryMethod( azureService, roleName, true, cacheWorkerRoleName, webRole.Startup, webRole.Endpoints, webRole.LocalResources, ref configurationSettings, CacheRuntimeVersion); webRole.ConfigurationSettings = configurationSettings; } else { WorkerRole workerRole = azureService.Components.GetWorkerRole(roleName); workerRole.LocalResources = CloudServiceUtilities.InitializeIfNull<LocalResources>(workerRole.LocalResources); DefConfigurationSetting[] configurationSettings = workerRole.ConfigurationSettings; CachingConfigurationFactoryMethod( azureService, roleName, false, cacheWorkerRoleName, workerRole.Startup, workerRole.Endpoints, workerRole.LocalResources, ref configurationSettings, CacheRuntimeVersion); workerRole.ConfigurationSettings = configurationSettings; } // Save changes azureService.Components.Save(azureService.Paths); message = string.Format(Resources.EnableMemcacheMessage, roleName, cacheWorkerRoleName, Resources.MemcacheEndpointPort); }
private void UpdateServiceConfigurations(AzureService service, string forwarderName) { foreach (ServiceConfiguration config in new[] { service.Components.LocalConfig, service.Components.CloudConfig }) { foreach (ServiceConfigurationSchema.RoleSettings role in config.Role) { if (role.ConfigurationSettings != null) { ServiceConfigurationSchema.ConfigurationSetting setting = role.ConfigurationSettings. FirstOrDefault<ServiceConfigurationSchema.ConfigurationSetting>(t => t.name.Equals( "Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled")); if (setting != null) { setting.value = "false"; } if (role.name == forwarderName) { ServiceConfigurationSchema.ConfigurationSetting forwarderSetting = role.ConfigurationSettings. FirstOrDefault<ServiceConfigurationSchema.ConfigurationSetting>(t => t.name.Equals( "Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled")); if (forwarderSetting != null) { forwarderSetting.value = "false"; } } } } } }
public WebRole EnableAzureMemcacheRoleProcess(string roleName, string cacheWorkerRoleName, string rootPath) { AzureService azureService = new AzureService(rootPath, null); if (string.IsNullOrEmpty(cacheWorkerRoleName)) { WorkerRole defaultCache = azureService.Components.Definition.WorkerRole.FirstOrDefault<WorkerRole>( w => w.Imports != null && w.Imports.Any(i => i.moduleName.Equals(Resources.CachingModuleName))); if (defaultCache == null) { throw new Exception(Resources.NoCacheWorkerRoles); } cacheWorkerRoleName = defaultCache.name; } // Verify cache worker role exists if (!azureService.Components.RoleExists(cacheWorkerRoleName)) { throw new Exception(string.Format(Resources.RoleNotFoundMessage, cacheWorkerRoleName)); } WorkerRole cacheWorkerRole = azureService.Components.GetWorkerRole(cacheWorkerRoleName); // Verify that the cache worker role has proper caching configuration. if (!IsCacheWorkerRole(cacheWorkerRole)) { throw new Exception(string.Format(Resources.NotCacheWorkerRole, cacheWorkerRoleName)); } // Verify that user is not trying to enable cache on a cache worker role. if (roleName.Equals(cacheWorkerRole)) { throw new Exception(string.Format(Resources.InvalidCacheRoleName, roleName)); } // Verify role to enable cache on exists if (!azureService.Components.RoleExists(roleName)) { throw new Exception(string.Format(Resources.RoleNotFoundMessage, roleName)); } // Verify that caching is not enabled for the role if (IsCacheEnabled(azureService.Components.GetRoleStartup(roleName))) { throw new Exception(string.Format(Resources.CacheAlreadyEnabledMessage, roleName)); } // All validations passed, enable caching. string message = string.Empty; EnableMemcache(roleName, cacheWorkerRoleName, ref message, ref azureService); WriteVerbose(message); if (PassThru) { SafeWriteOutputPSObject(typeof(RoleSettings).FullName, Parameters.RoleName, roleName); } return azureService.Components.GetWebRole(roleName); }
/// <summary> /// Factory method to apply memcache required configuration based on the installed SDK version. /// </summary> /// <param name="azureService">The azure service instance</param> /// <param name="webRole">The web role to enable caching on</param> /// <param name="isWebRole">Flag indicating if the provided role is web or not</param> /// <param name="cacheWorkerRole">The memcache worker role name</param> /// <param name="startup">The role startup</param> /// <param name="endpoints">The role endpoints</param> /// <param name="localResources">The role local resources</param> /// <param name="configurationSettings">The role configuration settings</param> /// <param name="sdkVersion">The current SDK version</param> private void CachingConfigurationFactoryMethod( AzureService azureService, string roleName, bool isWebRole, string cacheWorkerRole, Startup startup, Endpoints endpoints, LocalResources localResources, ref DefConfigurationSetting[] configurationSettings, string sdkVersion) { switch (sdkVersion) { case SDKVersion.Version180: Version180Configuration( azureService, roleName, isWebRole, cacheWorkerRole, startup, endpoints, localResources, ref configurationSettings); break; default: throw new Exception(string.Format(Resources.AzureSdkVersionNotSupported, Resources.MinSupportAzureSdkVersion, Resources.MaxSupportAzureSdkVersion)); } }
/// <summary> /// Applies required configuration for enabling cache in SDK 1.8.0 version by: /// * Add MemcacheShim runtime installation. /// * Add startup task to install memcache shim on the client side. /// * Add default memcache internal endpoint. /// * Add cache diagnostic to local resources. /// * Add ClientDiagnosticLevel setting to service configuration. /// * Adjust web.config to enable auto discovery for the caching role. /// </summary> /// <param name="azureService">The azure service instance</param> /// <param name="webRole">The web role to enable caching on</param> /// <param name="isWebRole">Flag indicating if the provided role is web or not</param> /// <param name="cacheWorkerRole">The memcache worker role name</param> /// <param name="startup">The role startup</param> /// <param name="endpoints">The role endpoints</param> /// <param name="localResources">The role local resources</param> /// <param name="configurationSettings">The role configuration settings</param> private void Version180Configuration( AzureService azureService, string roleName, bool isWebRole, string cacheWorkerRole, Startup startup, Endpoints endpoints, LocalResources localResources, ref DefConfigurationSetting[] configurationSettings) { if (isWebRole) { // Generate cache scaffolding for web role azureService.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WebRole.ToString()), roleName, new Dictionary<string, object>()); // Adjust web.config to enable auto discovery for the caching role. string webCloudConfigPath = Path.Combine(azureService.Paths.RootPath, roleName, Resources.WebCloudConfig); string webConfigPath = Path.Combine(azureService.Paths.RootPath, roleName, Resources.WebConfigTemplateFileName); UpdateWebConfig(roleName, cacheWorkerRole, webCloudConfigPath); UpdateWebConfig(roleName, cacheWorkerRole, webConfigPath); } else { // Generate cache scaffolding for worker role Dictionary<string, object> parameters = new Dictionary<string, object>(); parameters[ScaffoldParams.RoleName] = cacheWorkerRole; azureService.GenerateScaffolding(Path.Combine(Resources.CacheScaffolding, RoleType.WorkerRole.ToString()), roleName, parameters); } // Add startup task to install memcache shim on the client side. string cacheRuntimeUri = CloudRuntimeCollection.GetRuntimeUrl(Resources.CacheRuntimeValue, CacheRuntimeVersion); Debug.Assert(!string.IsNullOrEmpty(cacheRuntimeUri)); Variable emulated = new Variable { name = Resources.EmulatedKey, RoleInstanceValue = new RoleInstanceValueElement { xpath = "/RoleEnvironment/Deployment/@emulated" } }; Variable[] env = { emulated, new Variable { name = Resources.CacheRuntimeUrl, value = cacheRuntimeUri } }; Task shimStartupTask = new Task { Environment = env, commandLine = Resources.CacheStartupCommand, executionContext = ExecutionContext.elevated }; startup.Task = CloudServiceUtilities.ExtendArray<Task>(startup.Task, shimStartupTask); // Add default memcache internal endpoint. InternalEndpoint memcacheEndpoint = new InternalEndpoint { name = Resources.MemcacheEndpointName, protocol = InternalProtocol.tcp, port = Resources.MemcacheEndpointPort }; endpoints.InternalEndpoint = CloudServiceUtilities.ExtendArray<InternalEndpoint>(endpoints.InternalEndpoint, memcacheEndpoint); // Enable cache diagnostic LocalStore localStore = new LocalStore { name = Resources.CacheDiagnosticStoreName, cleanOnRoleRecycle = false }; localResources.LocalStorage = CloudServiceUtilities.ExtendArray<LocalStore>(localResources.LocalStorage, localStore); DefConfigurationSetting diagnosticLevel = new DefConfigurationSetting { name = Resources.CacheClientDiagnosticLevelAssemblyName }; configurationSettings = CloudServiceUtilities.ExtendArray<DefConfigurationSetting>(configurationSettings, diagnosticLevel); // Add ClientDiagnosticLevel setting to service configuration. AddClientDiagnosticLevelToConfig(azureService.Components.GetCloudConfigRole(roleName)); AddClientDiagnosticLevelToConfig(azureService.Components.GetLocalConfigRole(roleName)); }
public void GetNextPortWithEmptyPortIndpoints() { using (FileSystemHelper files = new FileSystemHelper(this)) { int expectedPort = int.Parse(Resources.DefaultPort); AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); service.Components.Definition.WebRole[0].Endpoints.InputEndpoint = null; service.Components.Save(service.Paths); service.AddWebRole(Data.PHPWebRoleScaffoldingPath); service = new AzureServiceWrapper(service.Paths.RootPath, null); int nextPort = service.Components.GetNextPort(); Assert.AreEqual<int>(expectedPort, nextPort); } }