protected override void PerformOperation(IServiceManagement channel) { UpgradeDeploymentInput input = new UpgradeDeploymentInput { Configuration = Utility.GetSettings(ConfigFileLocation), Mode = Mode, RoleToUpgrade = RoleToUpgrade, }; if (!string.IsNullOrEmpty(PackageLocation)) { input.PackageUrl = new Uri(PackageLocation); } if (!string.IsNullOrEmpty(Label)) { input.Label = ServiceManagementHelper.EncodeToBase64String(Label); } if (TreatWarningsAsError) { input.TreatWarningsAsError = TreatWarningsAsError; } Console.WriteLine("Upgrading Deployment"); if (!string.IsNullOrEmpty(DeploymentName)) { channel.UpgradeDeployment(SubscriptionId, HostedServiceName, DeploymentName, input); } else if (!string.IsNullOrEmpty(DeploymentSlot)) { channel.UpgradeDeploymentBySlot(SubscriptionId, HostedServiceName, DeploymentSlot, input); } }
public void SetAffinityGroupProcess() { this.ValidateParameters(); using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { UpdateAffinityGroupInput updateAffinityGroupInput = new UpdateAffinityGroupInput(); updateAffinityGroupInput.Label = ServiceManagementHelper.EncodeToBase64String(this.Label); UpdateAffinityGroupInput description = updateAffinityGroupInput; if (this.Description != null) { description.Description = this.Description; } CmdletExtensions.WriteVerboseOutputForObject(this, description); base.RetryCall((string s) => base.Channel.UpdateAffinityGroup(s, this.Name, description)); Operation operation = base.WaitForOperation(base.CommandRuntime.ToString()); ManagementOperationContext managementOperationContext = new ManagementOperationContext(); managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString()); managementOperationContext.set_OperationId(operation.OperationTrackingId); managementOperationContext.set_OperationStatus(operation.Status); ManagementOperationContext managementOperationContext1 = managementOperationContext; base.WriteObject(managementOperationContext1, true); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; this.WriteErrorDetails(communicationException); } } }
private UpgradeDeploymentInput CreateUpgradeInput() { string deploymentName = this.DeploymentName.Get(this.ActivityContext); if (string.IsNullOrEmpty(deploymentName)) { deploymentName = Guid.NewGuid().ToString(); } string package = this.PackageUrl.Get(this.ActivityContext); Uri packageUrl; if (package.StartsWith(Uri.UriSchemeHttp, StringComparison.OrdinalIgnoreCase) || package.StartsWith(Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) { packageUrl = new Uri(package); } else { throw new InvalidOperationException("You must upload the blob to Azure before creating a new deployment."); } return(new UpgradeDeploymentInput { PackageUrl = packageUrl, Configuration = Utility.GetConfiguration(this.ConfigurationFilePath.Get(this.ActivityContext)), Label = ServiceManagementHelper.EncodeToBase64String(this.DeploymentLabel.Get(this.ActivityContext)), RoleToUpgrade = this.RoleName.Get(this.ActivityContext), Mode = "Auto", TreatWarningsAsError = this.TreatWarningsAsErrors.Get(this.ActivityContext) }); }
/// <summary> /// Create a hosted Azure service. /// </summary> private void CreateHostedService() { Debug.Assert( !string.IsNullOrEmpty(_hostedServiceName), "_hostedServiceName cannot be null or empty."); Debug.Assert( !string.IsNullOrEmpty(_deploymentSettings.Label), "Label cannot be null or empty."); Debug.Assert( !string.IsNullOrEmpty(_deploymentSettings.ServiceSettings.Location), "Location cannot be null or empty."); SafeWriteObjectWithTimestamp(Resources.PublishCreatingServiceMessage); CreateHostedServiceInput hostedServiceInput = new CreateHostedServiceInput { ServiceName = _hostedServiceName, Label = ServiceManagementHelper.EncodeToBase64String(_deploymentSettings.Label), Location = _deploymentSettings.ServiceSettings.Location }; InvokeInOperationContext(() => { RetryCall(subscription => Channel.CreateHostedService(subscription, hostedServiceInput)); SafeWriteObjectWithTimestamp(String.Format(Resources.PublishCreatedServiceMessage, hostedServiceInput.ServiceName)); }); }
public override void ExecuteCmdlet() { base.ExecuteCmdlet(); if (Service.IsPresent) { IsDNSAvailable(CurrentSubscription.SubscriptionId, Name); } else if (Storage.IsPresent) { IsStorageServiceAvailable(CurrentSubscription.SubscriptionId, Name); } else { if (serviceBusChannel == null) { serviceBusChannel = ServiceManagementHelper.CreateServiceManagementChannel <IServiceBusManagement>( ServiceBinding, new Uri(ServiceEndpoint), CurrentSubscription.Certificate, new HttpRestMessageInspector(text => this.WriteDebug(text))); } IsServiceBusNamespaceAvailable(CurrentSubscription.SubscriptionId, Name); } }
public void NewAffinityGroupProcess() { using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { CreateAffinityGroupInput createAffinityGroupInput = new CreateAffinityGroupInput(); createAffinityGroupInput.Description = this.Description; createAffinityGroupInput.Label = ServiceManagementHelper.EncodeToBase64String(this.Label); createAffinityGroupInput.Location = this.Location; createAffinityGroupInput.Name = this.Name; CmdletExtensions.WriteVerboseOutputForObject(this, createAffinityGroupInput); base.RetryCall((string s) => base.Channel.CreateAffinityGroup(s, createAffinityGroupInput)); Operation operation = base.WaitForOperation(base.CommandRuntime.ToString()); ManagementOperationContext managementOperationContext = new ManagementOperationContext(); managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString()); managementOperationContext.set_OperationId(operation.OperationTrackingId); managementOperationContext.set_OperationStatus(operation.Status); ManagementOperationContext managementOperationContext1 = managementOperationContext; base.WriteObject(managementOperationContext1, true); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; this.WriteErrorDetails(communicationException); } } }
/// <summary> /// Create an Azure storage account that we can use to upload our /// package when creating and deploying a service. /// </summary> private void CreateStorageAccount() { Debug.Assert( !string.IsNullOrEmpty(_deploymentSettings.ServiceSettings.StorageAccountName), "StorageAccountName cannot be null or empty."); Debug.Assert( !string.IsNullOrEmpty(_deploymentSettings.Label), "Label cannot be null or empty."); Debug.Assert( !string.IsNullOrEmpty(_deploymentSettings.ServiceSettings.Location), "Location cannot be null or empty."); CreateStorageServiceInput storageServiceInput = new CreateStorageServiceInput { ServiceName = _deploymentSettings.ServiceSettings.StorageAccountName, Label = ServiceManagementHelper.EncodeToBase64String(_deploymentSettings.Label), Location = _deploymentSettings.ServiceSettings.Location }; InvokeInOperationContext(() => { RetryCall(subscription => Channel.CreateStorageAccount(subscription, storageServiceInput)); StorageService storageService = null; do { storageService = RetryCall(subscription => Channel.GetStorageService(subscription, storageServiceInput.ServiceName)); }while (storageService.StorageServiceProperties.Status != StorageAccountStatus.Created); }); }
/// <summary> /// Create a new deployment for the service. /// </summary> private void CreateNewDeployment() { Debug.Assert( !string.IsNullOrEmpty(_hostedServiceName), "_hostedServiceName cannot be null or empty."); Debug.Assert( !string.IsNullOrEmpty(_deploymentSettings.ServiceSettings.Slot), "Slot cannot be null or empty."); CreateDeploymentInput deploymentInput = new CreateDeploymentInput { PackageUrl = UploadPackage(), Configuration = GetConfiguration(), Label = ServiceManagementHelper.EncodeToBase64String(_deploymentSettings.Label), Name = _deploymentSettings.DeploymentName, StartDeployment = true, }; InvokeInOperationContext(() => { RetryCall(subscription => Channel.CreateOrUpdateDeployment( subscription, _hostedServiceName, _deploymentSettings.ServiceSettings.Slot, deploymentInput)); WaitForDeploymentToStart(); }); }
/// <summary> /// Upgrade the deployment for the service. /// </summary> private void UpgradeDeployment() { Debug.Assert( !string.IsNullOrEmpty(_hostedServiceName), "_hostedServiceName cannot be null or empty."); Debug.Assert( !string.IsNullOrEmpty(_deploymentSettings.Label), "Label cannot be null or empty."); Debug.Assert( !string.IsNullOrEmpty(_deploymentSettings.DeploymentName), "DeploymentName cannot be null or empty."); UpgradeDeploymentInput deploymentInput = new UpgradeDeploymentInput { PackageUrl = UploadPackage(), Configuration = GetConfiguration(), Label = ServiceManagementHelper.EncodeToBase64String(_deploymentSettings.Label), Mode = UpgradeType.Auto }; InvokeInOperationContext(() => { SafeWriteObjectWithTimestamp(Resources.PublishUpgradingMessage); RetryCall(subscription => Channel.UpgradeDeployment( subscription, _hostedServiceName, _deploymentSettings.DeploymentName, deploymentInput)); WaitForDeploymentToStart(); }); }
protected override IServiceManagement CreateChannel() { // If ShareChannel is set by a unit test, use the same channel that // was passed into out constructor. This allows the test to submit // a mock that we use for all network calls. if (ShareChannel) { return(Channel); } if (ServiceBinding == null) { ServiceBinding = ConfigurationConstants.WebHttpBinding(this.MaxStringContentLength); } if (string.IsNullOrEmpty(CurrentSubscription.ServiceEndpoint)) { ServiceEndpoint = ConfigurationConstants.ServiceManagementEndpoint; } else { ServiceEndpoint = CurrentSubscription.ServiceEndpoint; } return(ServiceManagementHelper.CreateServiceManagementChannel(this.ServiceBinding, new Uri(this.ServiceEndpoint), CurrentSubscription.Certificate)); }
protected override void PerformOperation(IServiceManagement channel) { CreateDeploymentInput input = new CreateDeploymentInput { Name = DeploymentName, Configuration = Utility.GetSettings(ConfigFileLocation), }; if (!string.IsNullOrEmpty(PackageLocation)) { input.PackageUrl = new Uri(PackageLocation); } if (!string.IsNullOrEmpty(Label)) { input.Label = ServiceManagementHelper.EncodeToBase64String(Label); } if (TreatWarningsAsError) { input.TreatWarningsAsError = TreatWarningsAsError; } Console.WriteLine("Creating Deployment... Name: {0}, Label: {1}", DeploymentName, Label); channel.CreateOrUpdateDeployment(SubscriptionId, HostedServiceName, DeploymentSlot, input); }
protected override void ProcessRecord() { Uri uri; string diskLabel; try { base.ProcessRecord(); this.ValidateParameters(); if (string.IsNullOrEmpty(this.Label)) { this.Label = this.Name; } this.Label = ServiceManagementHelper.EncodeToBase64String(this.Label); PersistentVM persistentVM = new PersistentVM(); persistentVM.AvailabilitySetName = this.AvailabilitySetName; persistentVM.ConfigurationSets = new Collection <ConfigurationSet>(); persistentVM.DataVirtualHardDisks = new Collection <DataVirtualHardDisk>(); persistentVM.RoleName = this.Name; persistentVM.RoleSize = this.InstanceSize; persistentVM.RoleType = "PersistentVMRole"; persistentVM.Label = this.Label; PersistentVM persistentVM1 = persistentVM; PersistentVM persistentVM2 = persistentVM1; OSVirtualHardDisk oSVirtualHardDisk = new OSVirtualHardDisk(); oSVirtualHardDisk.DiskName = this.DiskName; oSVirtualHardDisk.SourceImageName = this.ImageName; OSVirtualHardDisk oSVirtualHardDisk1 = oSVirtualHardDisk; if (string.IsNullOrEmpty(this.MediaLocation)) { uri = null; } else { uri = new Uri(this.MediaLocation); } oSVirtualHardDisk1.MediaLink = uri; oSVirtualHardDisk.HostCaching = this.HostCaching; OSVirtualHardDisk oSVirtualHardDisk2 = oSVirtualHardDisk; if (string.IsNullOrEmpty(this.DiskLabel)) { diskLabel = null; } else { diskLabel = this.DiskLabel; } oSVirtualHardDisk2.DiskLabel = diskLabel; persistentVM2.OSVirtualHardDisk = oSVirtualHardDisk; CmdletExtensions.WriteVerboseOutputForObject(this, persistentVM1); base.WriteObject(persistentVM1, true); } catch (Exception exception1) { Exception exception = exception1; base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null)); } }
public void SetRoleInstanceCountProcess() { Func <XElement, bool> func = null; this.GetCurrentDeployment(); if (this.currentDeployment != null) { using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { XNamespace xNamespace = "http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration"; XDocument xDocument = XDocument.Parse(ServiceManagementHelper.DecodeFromBase64String(this.currentDeployment.Configuration)); IEnumerable <XElement> xElements = xDocument.Root.Elements(xNamespace + "Role"); if (func == null) { func = (XElement p) => string.Compare(p.Attribute("name").Value, this.RoleName, true) == 0; } XElement xElement = xElements.Where <XElement>(func).SingleOrDefault <XElement>(); if (xElement != null) { xElement.Element(xNamespace + "Instances").SetAttributeValue("count", this.Count); } using (OperationContextScope operationContextScope1 = new OperationContextScope((IContextChannel)base.Channel)) { ChangeConfigurationInput changeConfigurationInput = new ChangeConfigurationInput(); changeConfigurationInput.Configuration = ServiceManagementHelper.EncodeToBase64String(xDocument.ToString()); ChangeConfigurationInput changeConfigurationInput1 = changeConfigurationInput; CmdletExtensions.WriteVerboseOutputForObject(this, xDocument); base.RetryCall((string s) => base.Channel.ChangeConfigurationBySlot(s, this.ServiceName, this.Slot, changeConfigurationInput1)); Operation operation = base.WaitForOperation(base.CommandRuntime.ToString()); ManagementOperationContext managementOperationContext = new ManagementOperationContext(); managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString()); managementOperationContext.set_OperationId(operation.OperationTrackingId); managementOperationContext.set_OperationStatus(operation.Status); ManagementOperationContext managementOperationContext1 = managementOperationContext; base.WriteObject(managementOperationContext1, true); } } catch (EndpointNotFoundException endpointNotFoundException1) { EndpointNotFoundException endpointNotFoundException = endpointNotFoundException1; this.WriteErrorDetails(endpointNotFoundException); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; this.WriteErrorDetails(communicationException); } } return; } else { return; } }
internal static void LogObject(OperatingSystem operatingSystem) { if (operatingSystem == null) { return; } Console.WriteLine("Operating System Version:{0}", operatingSystem.Version); Console.WriteLine("Operating System Label:{0}", ServiceManagementHelper.DecodeFromBase64String(operatingSystem.Label)); Console.WriteLine("Operating System IsDefault:{0}", operatingSystem.IsDefault); Console.WriteLine("Operating System IsActive:{0}", operatingSystem.IsActive); }
public DeploymentInfoContext(Microsoft.Samples.WindowsAzure.ServiceManagement.Deployment innerDeployment) { this.innerDeployment = innerDeployment; if (this.innerDeployment.RoleInstanceList != null) { this.RoleInstanceList = new List <RoleInstance>(); foreach (var roleInstance in this.innerDeployment.RoleInstanceList) { this.RoleInstanceList.Add(new RoleInstance(roleInstance)); } } if (!string.IsNullOrEmpty(this.innerDeployment.Configuration)) { string xmlString = ServiceManagementHelper.DecodeFromBase64String(this.innerDeployment.Configuration); // Ensure that the readers are properly disposed StringReader stringReader = null; try { stringReader = new StringReader(xmlString); using (var reader = XmlReader.Create(stringReader)) { stringReader = null; XDocument doc = XDocument.Load(reader); this.OSVersion = doc.Root.Attribute("osVersion") != null? doc.Root.Attribute("osVersion").Value: string.Empty; this.RolesConfiguration = new Dictionary <string, RoleConfiguration>(); var roles = doc.Root.Descendants(this.ns + "Role"); foreach (var role in roles) { this.RolesConfiguration.Add(role.Attribute("name").Value, new RoleConfiguration(role)); } } } finally { if (stringReader != null) { stringReader.Dispose(); } } } }
protected override IServiceManagement CreateChannel() { if (ServiceBinding == null) { ServiceBinding = ConfigurationConstants.WebHttpBinding(); } ServiceEndpoint = string.IsNullOrEmpty(CurrentSubscription.ServiceEndpoint) ? ConfigurationConstants.ServiceManagementEndpoint : CurrentSubscription.ServiceEndpoint; return(ServiceManagementHelper.CreateServiceManagementChannel(ServiceBinding, new Uri(ServiceEndpoint), CurrentSubscription.Certificate)); }
/// <summary> /// Connect to the Azure Management Service. /// </summary> /// <returns>An instance of the WCF service interface.</returns> protected IServiceManagement CreateChannel() { if (this.ServiceBinding == null) { this.ServiceBinding = ConfigurationConstants.WebHttpBinding(); } if (string.IsNullOrEmpty(this.ServiceEndpoint)) { this.ServiceEndpoint = ConfigurationConstants.ServiceEndpoint; } return(ServiceManagementHelper.CreateServiceManagementChannel(this.ServiceBinding, new Uri(this.ServiceEndpoint), this.ManagementCertificate)); }
internal static string GetSettings(string settingsFile) { string settings = null; try { settings = String.Join("", File.ReadAllLines(Path.GetFullPath(settingsFile))); } catch (Exception) { Console.WriteLine("Error reading settings from file: " + settingsFile); throw; } return ServiceManagementHelper.EncodeToBase64String(settings); }
protected override void ProcessRecord() { try { base.ProcessRecord(); Operation operation = null; OperatingSystemList oSVersionsProcess = this.GetOSVersionsProcess(out operation); IEnumerable <OSVersionsContext> oSVersionsContexts = oSVersionsProcess.Select <OperatingSystem, OSVersionsContext>((OperatingSystem os) => { string str; string str1; OSVersionsContext oSVersionsContext = new OSVersionsContext(); oSVersionsContext.set_OperationId(operation.OperationTrackingId); oSVersionsContext.set_OperationDescription(this.CommandRuntime.ToString()); oSVersionsContext.set_OperationStatus(operation.Status); oSVersionsContext.Family = os.Family; OSVersionsContext oSVersionsContext1 = oSVersionsContext; if (string.IsNullOrEmpty(os.FamilyLabel)) { str = null; } else { str = ServiceManagementHelper.DecodeFromBase64String(os.FamilyLabel); } oSVersionsContext1.FamilyLabel = str; oSVersionsContext.IsActive = os.IsActive; oSVersionsContext.IsDefault = os.IsDefault; oSVersionsContext.Version = os.Version; OSVersionsContext oSVersionsContext2 = oSVersionsContext; if (string.IsNullOrEmpty(os.Label)) { str1 = null; } else { str1 = ServiceManagementHelper.DecodeFromBase64String(os.Label); } oSVersionsContext2.Label = str1; return(oSVersionsContext); } ); base.WriteObject(oSVersionsContexts, true); } catch (Exception exception1) { Exception exception = exception1; base.WriteError(new ErrorRecord(exception, string.Empty, ErrorCategory.CloseError, null)); } }
internal static void LogObject(OperatingSystemFamilyList operatingSystemFamilyList) { if (operatingSystemFamilyList == null) { return; } Console.WriteLine("OperatingSystemFamilyList contains {0} item(s).", operatingSystemFamilyList.Count); foreach (var item in operatingSystemFamilyList) { Console.WriteLine("OperatingSystemFamily Name:{0}", item.Name); Console.WriteLine("OperatingSystemFamily Label:{0}", ServiceManagementHelper.DecodeFromBase64String(item.Label)); Console.WriteLine("Operating Systems in this family:"); LogObject(item.OperatingSystems); } }
/// <summary> /// Creates new WebsitesClient. /// </summary> /// <param name="subscription">The Windows Azure subscription data object</param> /// <param name="logger">The logger action</param> public WebsitesClient(SubscriptionData subscription, Action <string> logger) { SubscriptionId = subscription.SubscriptionId; Logger = logger; WebsiteChannel = ServiceManagementHelper.CreateServiceManagementChannel <IWebsitesServiceManagement>( ConfigurationConstants.WebHttpBinding(), new Uri(subscription.ServiceEndpoint), subscription.Certificate, new HttpRestMessageInspector(logger)); ServiceManagementChannel = ServiceManagementHelper.CreateServiceManagementChannel <IServiceManagement>( ConfigurationConstants.WebHttpBinding(), new Uri(subscription.ServiceEndpoint), subscription.Certificate, new HttpRestMessageInspector(logger)); }
internal static void LogObject(AffinityGroup affinityGroup) { if (affinityGroup == null) return; Console.WriteLine("AffinityGroup Name:{0}", affinityGroup.Name); if (!string.IsNullOrEmpty(affinityGroup.Label)) { Console.WriteLine("AffinityGroup Label:{0}", ServiceManagementHelper.DecodeFromBase64String(affinityGroup.Label)); } Console.WriteLine("AffinityGroup Description:{0}", affinityGroup.Description); Console.WriteLine("AffinityGroup Location:{0}", affinityGroup.Location); LogObject(affinityGroup.HostedServices); LogObject(affinityGroup.StorageServices); }
protected IDeploymentServiceManagement CreateDeploymentChannel(Repository repository) { // If ShareChannel is set by a unit test, use the same channel that // was passed into out constructor. This allows the test to submit // a mock that we use for all network calls. if (ShareChannel) { return(DeploymentChannel); } return(ServiceManagementHelper.CreateServiceManagementChannel <IDeploymentServiceManagement>( new Uri(repository.RepositoryUri), repository.PublishingUsername, repository.PublishingPassword, new HttpRestMessageInspector(WriteDebug))); }
public void NewHostedServiceProcess() { string serviceName; Action <string> action = null; CreateHostedServiceInput createHostedServiceInput = new CreateHostedServiceInput(); createHostedServiceInput.ServiceName = this.ServiceName; if (string.IsNullOrEmpty(this.Label)) { serviceName = this.ServiceName; } else { serviceName = this.Label; } string str = serviceName; createHostedServiceInput.Label = ServiceManagementHelper.EncodeToBase64String(str); createHostedServiceInput.Description = this.Description; createHostedServiceInput.AffinityGroup = this.AffinityGroup; createHostedServiceInput.Location = this.Location; using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { CmdletExtensions.WriteVerboseOutputForObject(this, createHostedServiceInput); NewAzureServiceCommand newAzureServiceCommand = this; if (action == null) { action = (string s) => base.Channel.CreateHostedService(s, createHostedServiceInput); } ((CmdletBase <IServiceManagement>)newAzureServiceCommand).RetryCall(action); Operation operation = base.WaitForOperation(base.CommandRuntime.ToString()); ManagementOperationContext managementOperationContext = new ManagementOperationContext(); managementOperationContext.set_OperationDescription(base.CommandRuntime.ToString()); managementOperationContext.set_OperationId(operation.OperationTrackingId); managementOperationContext.set_OperationStatus(operation.Status); ManagementOperationContext managementOperationContext1 = managementOperationContext; base.WriteObject(managementOperationContext1, true); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; this.WriteErrorDetails(communicationException); } } }
internal static void LogObject(Deployment deployment) { if (deployment == null) return; Console.WriteLine("Name:{0}", deployment.Name); Console.WriteLine("Label:{0}", ServiceManagementHelper.DecodeFromBase64String(deployment.Label)); Console.WriteLine("Url:{0}", deployment.Url.ToString()); Console.WriteLine("Status:{0}", deployment.Status); Console.WriteLine("DeploymentSlot:{0}", deployment.DeploymentSlot); Console.WriteLine("PrivateID:{0}", deployment.PrivateID); Console.WriteLine("UpgradeDomainCount:{0}", deployment.UpgradeDomainCount); LogObject(deployment.RoleList); LogObject(deployment.RoleInstanceList); LogObject(deployment.UpgradeStatus); }
protected override void PerformOperation(IServiceManagement channel) { if (!String.IsNullOrEmpty(Label)) { Label = ServiceManagementHelper.EncodeToBase64String(Label); } UpdateHostedServiceInput input = new UpdateHostedServiceInput() { Label = CSManageCommand.Label, Description = CSManageCommand.Description }; Console.WriteLine("Updating hosted service {0}", HostedServiceName); channel.UpdateHostedService(SubscriptionId, HostedServiceName, input); }
internal static void LogObject(HostedServiceProperties hostedServiceProperties) { if (hostedServiceProperties == null) return; Console.WriteLine("HostedService Label:{0}", ServiceManagementHelper.DecodeFromBase64String(hostedServiceProperties.Label)); Console.WriteLine("HostedService Description:{0}", hostedServiceProperties.Description); if (!string.IsNullOrEmpty(hostedServiceProperties.AffinityGroup)) { Console.WriteLine("HostedService AffinityGroupName:{0}", hostedServiceProperties.AffinityGroup); } if (!string.IsNullOrEmpty(hostedServiceProperties.Location)) { Console.WriteLine("HostedService Location:{0}", hostedServiceProperties.Location); } }
public void SetStorageAccountProcess() { if (this.Label == null && this.Description == null) { base.ThrowTerminatingError(new ErrorRecord(new Exception("You must specify a value for either Label or Description."), string.Empty, ErrorCategory.InvalidData, null)); } using (OperationContextScope operationContextScope = new OperationContextScope((IContextChannel)base.Channel)) { try { UpdateStorageServiceInput updateStorageServiceInput = new UpdateStorageServiceInput(); bool?geoReplicationEnabled = this.GeoReplicationEnabled; if (geoReplicationEnabled.HasValue) { bool?nullable = this.GeoReplicationEnabled; updateStorageServiceInput.GeoReplicationEnabled = new bool?(nullable.Value); } if (this.Description != null) { updateStorageServiceInput.Description = this.Description; } if (this.Label != null) { updateStorageServiceInput.Label = ServiceManagementHelper.EncodeToBase64String(this.Label); } CmdletExtensions.WriteVerboseOutputForObject(this, updateStorageServiceInput); base.RetryCall((string s) => base.Channel.UpdateStorageService(s, this.StorageAccountName, updateStorageServiceInput)); Operation operation = base.WaitForOperation(base.CommandRuntime.ToString()); ManagementOperationContext managementOperationContext = new ManagementOperationContext(); managementOperationContext.OperationDescription = base.CommandRuntime.ToString(); managementOperationContext.OperationId = operation.OperationTrackingId; managementOperationContext.OperationStatus = operation.Status; ManagementOperationContext managementOperationContext1 = managementOperationContext; base.WriteObject(managementOperationContext1, true); } catch (CommunicationException communicationException1) { CommunicationException communicationException = communicationException1; this.WriteErrorDetails(communicationException); } } }
protected override void PerformOperation(IServiceManagement channel) { CreateHostedServiceInput input = new CreateHostedServiceInput() { ServiceName = HostedServiceName, Label = ServiceManagementHelper.EncodeToBase64String(CSManageCommand.Label), Description = CSManageCommand.Description }; if (AffinityGroupName != null) { input.AffinityGroup = AffinityGroupName; } else if (LocationConstraintName != null) { input.Location = LocationConstraintName; } Console.WriteLine("Creating hosted service {0}", HostedServiceName); channel.CreateHostedService(SubscriptionId, input); }
/// <summary> /// Creates new instance from CloudServiceClient. /// </summary> /// <param name="subscription">The subscription data</param> /// <param name="debugStream">Action used to log http requests/responses</param> /// <param name="verboseStream">Action used to log detailed client progress</param> /// <param name="warningStream">Action used to log warning messages</param> public CloudServiceClient( SubscriptionData subscription, string currentLocation = null, Action <string> debugStream = null, Action <string> verboseStream = null, Action <string> warningStream = null) { Subscription = subscription; subscriptionId = subscription.SubscriptionId; CurrentDirectory = currentLocation; DebugStream = debugStream; VerboseStream = verboseStream; WarningeStream = warningStream; HeadersInspector = new HeadersInspector(); ServiceManagementChannel = ServiceManagementHelper.CreateServiceManagementChannel <IServiceManagement>( ConfigurationConstants.WebHttpBinding(), new Uri(subscription.ServiceEndpoint), subscription.Certificate, new HttpRestMessageInspector(DebugStream), HeadersInspector); CloudBlobUtility = new CloudBlobUtility(); }