public void RemoveAzureServiceProcessTest() { bool serviceDeleted = false; bool deploymentDeleted = false; channel.GetDeploymentBySlotThunk = ar => { if (deploymentDeleted) throw new ServiceManagementClientException(HttpStatusCode.NotFound, new ServiceManagementError(), string.Empty); return new Deployment{Name = serviceName, DeploymentSlot = ArgumentConstants.Slots[SlotType.Production], Status = 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]); } }
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 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.ValidSubscriptionName[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)); } }
public override void ExecuteCmdlet() { RootPath = RootPath ?? General.GetServiceRootPath(CurrentPath()); AzureService service = new AzureService(RootPath, null); RoleInfo roleInfo = null; if (isWebRole) { roleInfo = service.AddWebRole(Scaffolding, Name, Instances); } else { roleInfo = service.AddWorkerRole(Scaffolding, Name, Instances); } OnProcessing(roleInfo); try { service.ChangeRolePermissions(roleInfo); SafeWriteOutputPSObject(typeof(RoleSettings).FullName, Parameters.RoleName, roleInfo.Name); WriteVerbose(string.Format(successMessage, RootPath, roleInfo.Name)); } catch (UnauthorizedAccessException) { WriteWarning(Resources.AddRoleMessageInsufficientPermissions); } }
private void UpdateCacheWorkerRolesCloudConfiguration(PublishContext context) { string connectionString = GetStorageServiceConnectionString(context.ServiceSettings.StorageServiceName); AzureService cloudServiceProject = new AzureService(context.RootPath, null); ConfigConfigurationSetting connectionStringConfig = new ConfigConfigurationSetting { name = Resources.CachingConfigStoreConnectionStringSettingName, value = string.Empty }; cloudServiceProject.Components.ForEachRoleSettings( r => Array.Exists <ConfigConfigurationSetting>(r.ConfigurationSettings, c => c.Equals(connectionStringConfig)), delegate(RoleSettings r) { int index = Array.IndexOf <ConfigConfigurationSetting>(r.ConfigurationSettings, connectionStringConfig); r.ConfigurationSettings[index] = new ConfigConfigurationSetting { name = Resources.CachingConfigStoreConnectionStringSettingName, value = connectionString }; }); cloudServiceProject.Components.Save(cloudServiceProject.Paths); }
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(Resources.StopEmulatorMessage); service.StopEmulator(out standardOutput, out standardError); WriteVerbose(Resources.StoppedEmulatorMessage); 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 void SetAzureInstancesProcessTestsEmptyRoleNameFail() { using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); Testing.AssertThrows<ArgumentException>(() => service.SetRoleInstances(service.Paths, string.Empty, 10), string.Format(Resources.InvalidOrEmptyArgumentMessage, Resources.RoleName)); } }
public void SetAzureInstancesProcessNegativeRoleInstanceFail() { string roleName = "WebRole1"; using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); Testing.AssertThrows<ArgumentException>(() => service.SetRoleInstances(service.Paths, roleName, -1), string.Format(Resources.InvalidInstancesCount, roleName)); } }
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); } }
private void PrepareCloudServicePackagesRuntime(PublishContext context) { AzureService cloudServiceProject = new AzureService(context.RootPath, null); string warning = cloudServiceProject.ResolveRuntimePackageUrls(); if (!string.IsNullOrEmpty(warning)) { WriteWarning(Resources.RuntimeMismatchWarning, context.ServiceName); WriteWarning(warning); } }
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 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)); } }
private PublishContext CreatePublishContext( string name, string slot, string location, string affinityGroup, string storageServiceName, string deploymentName) { string serviceName; AzureService cloudServiceProject = GetCurrentServiceProject(); // If the name provided is different than existing name change it if (!string.IsNullOrEmpty(name) && name != cloudServiceProject.ServiceName) { cloudServiceProject.ChangeServiceName(name, cloudServiceProject.Paths); } // If there's no storage service provided, try using the default one if (string.IsNullOrEmpty(storageServiceName)) { storageServiceName = Subscription.CurrentStorageAccount; } // Use default location if not location and affinity group provided location = string.IsNullOrEmpty(location) && string.IsNullOrEmpty(affinityGroup) ? GetDefaultLocation() : location; ServiceSettings serviceSettings = ServiceSettings.LoadDefault( cloudServiceProject.Paths.Settings, slot, location, affinityGroup, Subscription.SubscriptionName, storageServiceName, name, cloudServiceProject.ServiceName, out serviceName ); PublishContext context = new PublishContext( serviceSettings, Path.Combine(GetCurrentDirectory(), cloudServiceProject.Paths.CloudPackage), Path.Combine(GetCurrentDirectory(), cloudServiceProject.Paths.CloudConfiguration), serviceName, deploymentName, cloudServiceProject.Paths.RootPath); return(context); }
public void TestStopAzureService() { stopServiceCmdlet.ServiceName = serviceName; stopServiceCmdlet.Slot = slot; cloudServiceClientMock.Setup(f => f.StopCloudService(serviceName, slot)); using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); stopServiceCmdlet.ExecuteCmdlet(); Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count); cloudServiceClientMock.Verify(f => f.StopCloudService(serviceName, slot), Times.Once()); } }
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; }
public WorkerRole AddAzureCacheWorkerRoleProcess(string workerRoleName, int instances, string rootPath) { // Create cache worker role. AzureService azureService = new AzureService(rootPath, null); RoleInfo nodeWorkerRole = azureService.AddWorkerRole(Path.Combine(Resources.GeneralScaffolding, RoleType.WorkerRole.ToString()), workerRoleName, instances); azureService = CachingConfigurationFactoryMethod(rootPath, nodeWorkerRole, new AzureTool().AzureSdkVersion); azureService.Components.Save(azureService.Paths); WorkerRole cacheWorkerRole = azureService.Components.GetWorkerRole(nodeWorkerRole.Name); // Write output SafeWriteOutputPSObject( cacheWorkerRole.GetType().FullName, Parameters.CacheWorkerRoleName, nodeWorkerRole.Name, Parameters.Instances, nodeWorkerRole.InstanceCount ); return azureService.Components.GetWorkerRole(workerRoleName); }
public void DisableRemoteDesktop() { AzureService service = new AzureService(General.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 SetAzureVMSizeProcessTestsCaseInsensitiveVMSizeSize() { string newRoleVMSize = "ExTraLaRge"; using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); string roleName = "WebRole1"; service.AddWebRole(Data.NodeWebRoleScaffoldingPath); cmdlet.PassThru = false; RoleSettings roleSettings = cmdlet.SetAzureVMSizeProcess("WebRole1", newRoleVMSize, service.Paths.RootPath); service = new AzureService(service.Paths.RootPath, null); Assert.AreEqual<string>(newRoleVMSize.ToLower(), service.Components.Definition.WebRole[0].vmsize.ToString().ToLower()); Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count); Assert.AreEqual<string>(roleName, roleSettings.name); } }
public void CreateCloudPackageWithMultipleRoles() { using (FileSystemHelper files = new FileSystemHelper(this)) { string standardOutput; string standardError; AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWorkerRole(Data.NodeWorkerRoleScaffoldingPath); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); service.AddWorkerRole(Data.PHPWorkerRoleScaffoldingPath); service.AddWebRole(Data.PHPWebRoleScaffoldingPath); service.CreatePackage(DevEnv.Cloud, out standardOutput, out standardError); using (Package package = Package.Open(service.Paths.CloudPackage)) { Assert.AreEqual(9, package.GetParts().Count()); } } }
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 TestSetAzureRuntimeInvalidRuntimeType() { using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); string roleName = "WebRole1"; service.AddWebRole(Data.NodeWebRoleScaffoldingPath); RoleSettings roleSettings1 = cmdlet.SetAzureRuntimesProcess(roleName, "noide", "0.8.99", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files)); RoleSettings roleSettings2 = cmdlet.SetAzureRuntimesProcess(roleName, "iisnoide", "0.9.99", service.Paths.RootPath, RuntimePackageHelper.GetTestManifest(files)); VerifyInvalidPackageJsonVersion(service.Paths.RootPath, roleName, "node", "*"); VerifyInvalidPackageJsonVersion(service.Paths.RootPath, roleName, "iisnode", "*"); Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[0]).Members[Parameters.RoleName].Value.ToString()); Assert.AreEqual<string>(roleName, ((PSObject)mockCommandRuntime.OutputPipeline[1]).Members[Parameters.RoleName].Value.ToString()); Assert.IsTrue(((PSObject)mockCommandRuntime.OutputPipeline[0]).TypeNames.Contains(typeof(RoleSettings).FullName)); Assert.IsTrue(((PSObject)mockCommandRuntime.OutputPipeline[1]).TypeNames.Contains(typeof(RoleSettings).FullName)); Assert.AreEqual<string>(roleName, roleSettings1.name); Assert.AreEqual<string>(roleName, roleSettings2.name); } }
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 OnPublish(IServiceManagement channel, AzureService service, ServiceSettings publishSettings, string subscriptionId) { StorageService storageService = channel.GetStorageKeys(subscriptionId, publishSettings.StorageAccountName); string name = publishSettings.StorageAccountName; string key = storageService.StorageServiceKeys.Primary; ConfigConfigurationSetting connectionStringConfig = new ConfigConfigurationSetting { name = Resources.CachingConfigStoreConnectionStringSettingName, value = string.Empty }; service.Components.ForEachRoleSettings( r => Array.Exists<ConfigConfigurationSetting>(r.ConfigurationSettings, c => c.Equals(connectionStringConfig)), delegate(RoleSettings r) { int index = Array.IndexOf<ConfigConfigurationSetting>(r.ConfigurationSettings, connectionStringConfig); r.ConfigurationSettings[index] = new ConfigConfigurationSetting { name = Resources.CachingConfigStoreConnectionStringSettingName, value = string.Format(Resources.CachingConfigStoreConnectionStringSettingValue, name, key) }; }); service.Components.Save(service.Paths); }
public void SetAzureInstancesProcessTestsCaseInsensitive() { int newRoleInstances = 10; using (FileSystemHelper files = new FileSystemHelper(this)) { AzureService service = new AzureService(files.RootPath, serviceName, null); string roleName = "WebRole1"; service.AddWebRole(Data.NodeWebRoleScaffoldingPath); cmdlet.PassThru = false; RoleSettings roleSettings = cmdlet.SetAzureInstancesProcess("WeBrolE1", newRoleInstances, service.Paths.RootPath); service = new AzureService(service.Paths.RootPath, null); Assert.AreEqual<int>(newRoleInstances, service.Components.CloudConfig.Role[0].Instances.count); Assert.AreEqual<int>(newRoleInstances, service.Components.LocalConfig.Role[0].Instances.count); Assert.AreEqual<int>(0, mockCommandRuntime.OutputPipeline.Count); Assert.AreEqual<int>(newRoleInstances, roleSettings.Instances.count); Assert.AreEqual<string>(roleName, roleSettings.name); } }
public void TestPublishNewCloudService() { 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); ExecuteInTempCurrentDirectory(rootPath, () => client.PublishCloudService(location: "West US")); serviceManagementChannelMock.Verify(f => f.BeginCreateOrUpdateDeployment( subscription.SubscriptionId, serviceName, DeploymentSlotType.Production, It.IsAny<CreateDeploymentInput>(), null, null), Times.Once()); } }
public void SetDeploymentStatusProcessWithNotExistingServiceFail() { string newStatus = DeploymentStatus.Running; string currentStatus = DeploymentStatus.Suspended; bool statusUpdated = false; channel.UpdateDeploymentStatusBySlotThunk = ar => { statusUpdated = true; channel.GetDeploymentBySlotThunk = ar2 => new Deployment{Name = serviceName, DeploymentSlot = slot, Status = newStatus}; }; channel.GetDeploymentBySlotThunk = ar => new Deployment{Name = serviceName, DeploymentSlot = slot, Status = currentStatus}; channel.IsDNSAvailableThunk = ida => new AvailabilityResponse { Result = true }; using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); AzureService service = new AzureService(files.RootPath, serviceName, null); startServiceCmdlet.SetDeploymentStatusProcess(service.Paths.RootPath, newStatus, slot, Data.ValidSubscriptionName[0], serviceName); Assert.IsFalse(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); }
private void AddCertificates(CertificateList uploadedCertificates, PublishContext context) { string name = context.ServiceName; AzureService cloudServiceProject = new AzureService(context.RootPath, null); if (cloudServiceProject.Components.CloudConfig.Role != null) { foreach (ConfigCertificate certElement in cloudServiceProject.Components.CloudConfig.Role. SelectMany(r => r.Certificates ?? new ConfigCertificate[0]).Distinct()) { if (uploadedCertificates == null || (uploadedCertificates.Count(c => c.Thumbprint.Equals( certElement.thumbprint, StringComparison.OrdinalIgnoreCase)) < 1)) { X509Certificate2 cert = General.GetCertificateFromStore(certElement.thumbprint); CertificateFile certFile = null; try { certFile = new CertificateFile { Data = Convert.ToBase64String(cert.Export(X509ContentType.Pfx, string.Empty)), Password = string.Empty, CertificateFormat = "pfx" }; } catch (CryptographicException exception) { throw new ArgumentException(string.Format( Resources.CertificatePrivateKeyAccessError, certElement.name), exception); } CallSync(() => ServiceManagementChannel.AddCertificates(subscriptionId, name, certFile)); } } } }
public void GetNextPortNullNodeWebEndpointAndNullWorkerRole() { using (FileSystemHelper files = new FileSystemHelper(this)) { int expectedPort = int.Parse(Resources.DefaultWebPort); AzureService service = new AzureService(files.RootPath, serviceName, null); service.AddWebRole(Data.NodeWebRoleScaffoldingPath); service = new AzureService(service.Paths.RootPath, null); service.Components.Definition.WebRole.ToList().ForEach(wr => wr.Endpoints = null); int nextPort = service.Components.GetNextPort(); Assert.AreEqual<int>(expectedPort, nextPort); } }
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); } }
/// <summary> /// Publishes a service project on Windows Azure. /// </summary> /// <param name="name">The cloud service name</param> /// <param name="slot">The deployment slot</param> /// <param name="location">The deployment location</param> /// <param name="affinityGroup">The deployment affinity group</param> /// <param name="storageAccount">The storage account to store the package</param> /// <param name="deploymentName">The deployment name</param> /// <param name="launch">Launch the service after publishing</param> /// <returns>The created deployment</returns> public Deployment PublishCloudService( string name = null, string slot = null, string location = null, string affinityGroup = null, string storageAccount = null, string deploymentName = null, bool launch = false) { // Initialize publish context PublishContext context = CreatePublishContext( name, slot, location, affinityGroup, storageAccount, deploymentName); WriteVerbose(string.Format(Resources.PublishServiceStartMessage, context.ServiceName)); // Set package runtime information WriteVerboseWithTimestamp(Resources.RuntimeDeploymentStart, context.ServiceName); PrepareCloudServicePackagesRuntime(context); // Verify storage account exists WriteVerboseWithTimestamp( Resources.PublishVerifyingStorageMessage, context.ServiceSettings.StorageServiceName); CreateStorageServiceIfNotExist( context.ServiceSettings.StorageServiceName, context.ServiceName, context.ServiceSettings.Location, context.ServiceSettings.AffinityGroup); // Update cache worker roles configuration WriteVerboseWithTimestamp( Resources.PublishPreparingDeploymentMessage, context.ServiceName, subscriptionId); UpdateCacheWorkerRolesCloudConfiguration(context); // Create cloud package AzureTool.Validate(); if (File.Exists(context.PackagePath)) { File.Delete(context.PackagePath); } AzureService cloudServiceProject = new AzureService(context.RootPath, null); string unused; cloudServiceProject.CreatePackage(DevEnv.Cloud, out unused, out unused); // Publish cloud service WriteVerboseWithTimestamp(Resources.PublishConnectingMessage); CreateCloudServiceIfNotExist( context.ServiceName, affinityGroup: context.ServiceSettings.AffinityGroup, location: context.ServiceSettings.Location); if (DeploymentExists(context.ServiceName, context.ServiceSettings.Slot)) { // Upgrade the deployment UpgradeDeployment(context); } else { // Create new deployment CreateDeployment(context); } // Get the deployment id and show it. WriteVerboseWithTimestamp(Resources.PublishCreatedDeploymentMessage, GetDeploymentId(context)); // Verify the deployment succeeded by checking that each of the roles are running VerifyDeployment(context); // Get object of the published deployment Deployment deployment = ServiceManagementChannel.GetDeploymentBySlot( subscriptionId, context.ServiceName, context.ServiceSettings.Slot); if (launch) { General.LaunchWebPage(deployment.Url.ToString()); } return(deployment); }
public void EnableDisableEnableRemoteDesktopForWebAndWorkerRoles() { using (FileSystemHelper files = new FileSystemHelper(this)) { files.CreateAzureSdkDirectoryAndImportPublishSettings(); string rootPath = files.CreateNewService("NEW_SERVICE"); addNodeWebCmdlet = new AddAzureNodeWebRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WebRole" }; addNodeWebCmdlet.ExecuteCmdlet(); addNodeWorkerCmdlet = new AddAzureNodeWorkerRoleCommand() { RootPath = rootPath, CommandRuntime = mockCommandRuntime, Name = "WorkerRole" }; addNodeWorkerCmdlet.ExecuteCmdlet(); EnableAzureRemoteDesktopCommandTest.EnableRemoteDesktop("user", "GoodPassword!"); disableRDCmdlet.DisableRemoteDesktop(); EnableAzureRemoteDesktopCommandTest.EnableRemoteDesktop("user", "GoodPassword!"); // Verify the roles have been setup with forwarding, access, // and certs AzureService service = new AzureService(rootPath, null); EnableAzureRemoteDesktopCommandTest.VerifyWebRole(service.Components.Definition.WebRole[0], false); EnableAzureRemoteDesktopCommandTest.VerifyWorkerRole(service.Components.Definition.WorkerRole[0], true); EnableAzureRemoteDesktopCommandTest.VerifyRoleSettings(service); } }
private static void VerifyDisableRoleSettings(AzureService service) { IEnumerable<RoleSettings> settings = Enumerable.Concat( service.Components.CloudConfig.Role, service.Components.LocalConfig.Role); foreach (RoleSettings roleSettings in settings) { Assert.AreEqual( 1, roleSettings.ConfigurationSettings .Where(c => c.name == "Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" && c.value == "false") .Count()); } }
/// <summary> /// Sets the VM size of the role. /// </summary> /// <param name="roleName">The role name</param> /// <param name="vmSize">The vm size</param> /// <param name="rootPath">The service root path</param> /// <returns>Role after updating VM size</returns> public RoleSettings SetAzureVMSizeProcess(string roleName, string vmSize, string rootPath) { AzureService service = new AzureService(rootPath, null); service.SetRoleVMSize(service.Paths, roleName, vmSize); if (PassThru) { SafeWriteOutputPSObject(typeof(RoleSettings).FullName, Parameters.RoleName, roleName); } return service.Components.GetCloudConfigRole(roleName); }