/// <summary> /// Calls the Create Storage Account operation in the Service Management /// REST API for the specified subscription, storage account name, /// description, label, location or affinity group, and geo-replication /// enabled setting. /// </summary> /// <param name="serviceName">The name of the storage account to update.</param> /// <param name="description">The new description for the storage account.</param> /// <param name="label">The new label for the storage account.</param> /// <param name="affinityGroup">The affinity group name, or null to use a location.</param> /// <param name="location">The location name, or null to use an affinity group.</param> /// <param name="geoReplicationEnabled">The new geo-replication setting, if applicable. /// This optional parameter defaults to null.</param> /// <returns>The requestId for the operation.</returns> public string CreateStorageAccount( string serviceName, string description, string label, string affinityGroup, string location, bool?geoReplicationEnabled = null) { string uriFormat = "https://management.core.windows.net/{0}" + "/services/storageservices"; Uri uri = new Uri(String.Format(uriFormat, requestInvoker.SubscriptionId)); // Location and Affinity Group are mutually exclusive. // Use the location if it isn't null or empty. XElement locationOrAffinityGroup = String.IsNullOrEmpty(location) ? new XElement(AzureRestAdapterConstants.NameSpaceWA + "AffinityGroup", affinityGroup) : new XElement(AzureRestAdapterConstants.NameSpaceWA + "Location", location); // Create the request XML document XDocument requestBody = new XDocument( new XDeclaration("1.0", "UTF-8", "no"), new XElement( AzureRestAdapterConstants.NameSpaceWA + "CreateStorageServiceInput", new XElement(AzureRestAdapterConstants.NameSpaceWA + "ServiceName", serviceName), new XElement(AzureRestAdapterConstants.NameSpaceWA + "Description", description), new XElement(AzureRestAdapterConstants.NameSpaceWA + "Label", label.ToBase64()), locationOrAffinityGroup)); // Add the GeoReplicationEnabled element if the version supports it. if ((geoReplicationEnabled != null) && (String.CompareOrdinal(AzureRestAdapterConstants.Version, "2011-12-01") >= 0)) { requestBody.Element( AzureRestAdapterConstants.NameSpaceWA + "CreateStorageServiceInput").Add( new XElement( AzureRestAdapterConstants.NameSpaceWA + "GeoReplicationEnabled", geoReplicationEnabled.ToString().ToLowerInvariant())); } XDocument responseBody; return(requestInvoker.InvokeRequest( uri, "POST", HttpStatusCode.Accepted, requestBody, out responseBody)); }
public string NewAzureDisk(string name, string label, string mediaLink) { string uriFormat = "https://management.core.windows.net/{0}/services/disks"; Uri uri = new Uri(String.Format(uriFormat, requestInvoker.SubscriptionId)); // Create the request XML document XDocument requestBody = new XDocument( new XDeclaration("1.0", "UTF-8", "no"), new XElement( AzureRestAdapterConstants.NameSpaceWA + "Disk", new XElement(AzureRestAdapterConstants.NameSpaceWA + "OS", "Windows"), new XElement(AzureRestAdapterConstants.NameSpaceWA + "Label", label.ToBase64()), new XElement(AzureRestAdapterConstants.NameSpaceWA + "MediaLink", mediaLink), new XElement(AzureRestAdapterConstants.NameSpaceWA + "Name", name))); XDocument responseBody; return(requestInvoker.InvokeRequest( uri, "POST", HttpStatusCode.OK, requestBody, out responseBody)); }