private List <IPEndPoint> GetServiceEndpoints() { ClientOutputMessageInspector messageInspector; IServiceManagement serviceProxy = ServiceInitializer.Get(this._cert, out messageInspector); WriteObject(String.Format(CultureInfo.InvariantCulture, Resources.FetchingEndpoints, ServiceName)); HostedService hostedService = serviceProxy.GetHostedServiceProperties(this._subscriptionId, this.ServiceName); List <IPEndPoint> endPointsToTest = new List <IPEndPoint>(); if (hostedService.Deployments != null && hostedService.Deployments.Length != 0) { foreach (Deployment eachDeployment in hostedService.Deployments) { if (eachDeployment.RoleList != null && eachDeployment.RoleList.Length != 0) { foreach (Role eachRole in eachDeployment.RoleList) { if (eachRole.ConfigurationSets != null && eachRole.ConfigurationSets.Length != 0) { foreach (ConfigurationSet eachConfigSet in eachRole.ConfigurationSets) { NetworkConfigurationSet networkConfigset = eachConfigSet as NetworkConfigurationSet; if (networkConfigset != null && networkConfigset.InputEndpoints != null && networkConfigset.InputEndpoints.Length != 0) { endPointsToTest.AddRange(networkConfigset.InputEndpoints.Select(eachEndpoint => new IPEndPoint(IPAddress.Parse(eachEndpoint.Vip), eachEndpoint.Port))); } } } } } } } return(endPointsToTest); }
private bool StorageAccountExists() { ClientOutputMessageInspector messageInspector; IServiceManagement serviceProxy = ServiceInitializer.Get(this._cert, out messageInspector); AvailabilityResponse response = serviceProxy.CheckStorageAccountNameAvailability(this._subscriptionId, this.StorageAccount); if (response.Result == false) //If storage account already exists..verify if it is located in same location supplied in input parameter. { StorageService storageAcctProperties; try { storageAcctProperties = serviceProxy.GetStorageAccountProperties(this._subscriptionId, this.StorageAccount); } catch (EndpointNotFoundException) { throw new ApplicationFailedException(string.Format(CultureInfo.InvariantCulture, Resources.StorageAccExistsForDiffSubscription, this.StorageAccount)); } if (string.IsNullOrEmpty(Location) == false && Location.Trim().ToUpperInvariant() != storageAcctProperties.StorageServiceProperties.Location.ToUpperInvariant()) { WriteWarning(Resources.StorageAccDiffLocationWarning); } } return(!response.Result); }
private void WaitTillCreationComplete() { bool isDone = false; while (isDone == false) { System.Threading.Thread.Sleep(5000); ClientOutputMessageInspector messageInspector; IServiceManagement serviceProxy = ServiceInitializer.Get(this._cert, out messageInspector); Operation status = serviceProxy.GetOperationStatus(this._subscriptionId, this._createRequestToken); _createStorageAccStatus = status.Status; WriteObject("Storage account creation status: " + _createStorageAccStatus); if (status.Status == OperationStatus.Succeeded) { break; } if (status.Status != OperationStatus.InProgress) { if (IsStorageAccountLimitExceeded() == true) { throw new ApplicationFailedException(Resources.StorageAccLimitReached); } else { throw new ApplicationFailedException(string.Format(CultureInfo.InvariantCulture, Resources.StorageAccCreationFailed, _createStorageAccStatus)); } } } }
private string GetStorageAccKey() { ClientOutputMessageInspector messageInspector; IServiceManagement serviceProxy = ServiceInitializer.Get(this._cert, out messageInspector); StorageService response = serviceProxy.GetStorageAccountKeys(this._subscriptionId, this.StorageAccount); return(response.StorageServiceKeys.Primary); }
private bool IsStorageAccountLimitExceeded() { WriteObject(Resources.VerifyStorageAccCount); ClientOutputMessageInspector messageInspector; IServiceManagement serviceProxy = ServiceInitializer.Get(this._cert, out messageInspector); ServiceProxy.Subscription subscriptionDetails = serviceProxy.GetSubscription(this._subscriptionId); if (subscriptionDetails.MaxStorageAccounts == subscriptionDetails.CurrentStorageAccounts) { return(true); } return(false); }