저장소 계정 업데이트

 

Update Storage Account 비동기 작업 레이블, 설명, 업데이트 및 설정 하거나 지정 된 저장소 계정에 대 한 지리적 복제 상태를 해제 합니다.

요청

Update Storage Account 요청을 다음과 같이 지정할 수 있습니다. 대체 <subscription-id> 구독 ID로 및 <service-name> 저장소 계정의 이름으로 합니다.

방법 요청 URI
PUT https://management.core.windows.net/<subscription-id>/services/storageservices/<service-name>

관리 서비스에 대한 요청이 안전한지 확인해야 합니다. 추가 세부 정보를 참조 하십시오. 서비스 관리 요청 인증.

URI 매개 변수

없음.

요청 헤더

다음 표에서는 요청 헤더에 대해 설명합니다.

요청 헤더 설명
Content-Type 필수 사항입니다. 이 헤더를 설정 application/xml합니다.
x-ms-version 필수 사항입니다. 이 요청에 사용할 작업의 버전을 지정합니다. 이 헤더의 값으로 설정 되어 있어야 2011-06-01 이상. 지역에서 복제 기능을 사용하려면 버전이 "2012-03-01" 이상이어야 합니다.

사용자 지정 도메인 기능을 사용하려면 버전이 "2013-06-01" 이상이어야 합니다.

SecondaryReadEnabled 기능을 사용하려면 버전이 "2013-11-01" 이상이어야 합니다.

버전 이어야 합니다. 적어도 "2014-06-01" 사용 하는 AccountType 필드입니다.GeoReplicationEnabledSecondaryReadEnabled 지원 되는 앞으로 – 해당 하는 기능에 포함 되어 더이상을 AccountType합니다.

버전 관리 헤더에 대 한 자세한 내용은 참조 서비스 관리 버전 관리.

요청 본문

요청 본문의 형식은 다음과 같습니다.

  
<?xml version="1.0" encoding="utf-8"?> <UpdateStorageServiceInput xmlns="https://schemas.microsoft.com/windowsazure"> <Description>description-of-storage-account</Description> <Label>base64-encoded-label</Label> <GeoReplicationEnabled>geo-replication-indicator</GeoReplicationEnabled> <ExtendedProperties> <ExtendedProperty> <Name>property-name</Name> <Value>property-value</Value> </ExtendedProperty> </ExtendedProperties> <CustomDomains> <CustomDomain> <Name>name-of-custom-domain</Name> <UseSubDomainName>cname-validation-indicator</UseSubDomainName> </CustomDomain> </CustomDomains> <SecondaryReadEnabled>secondary-read-indicator</SecondaryReadEnabled> <AccountType>type-of-storage-account</AccountType> </UpdateStorageServiceInput>  
  

다음 표에서는 요청 본문의 요소에 대해 설명합니다.

요소 이름 설명
Label 선택 사항입니다. 저장소 계정의 base-64로 인코딩된 이름을 지정합니다. 레이블의 길이는 최대 100자입니다. 저장소 계정을 식별하는 데 추적용으로 사용할 수 있는 레이블입니다. 하나에 대 한 값을 지정 해야 Label 또는 Description, 또는 둘 모두에 있습니다.
설명 선택 사항입니다. 저장소 계정에 대한 설명입니다. 설명의 길이는 최대 1024자입니다. 하나에 대 한 값을 지정 해야 Label 또는 Description, 또는 둘 모두에 있습니다.
GeoReplicationEnabled 선택 사항입니다. 지정한 저장소에 대한 지리적 복제를 사용 또는 사용 안 함으로 설정합니다. 경우 설정 true, 저장소 계정에 데이터가 심각한 서비스 중단 발생 시 복원 기능을 사용할 수 있는 둘 이상의 지리적 위치에 복제 됩니다. 경우 설정 false, 지리적 복제를 사용할 수 없습니다. 요청 본문에 요소가 포함되어 있지 않으면 현재 값이 계속 변경되지 않습니다. Important: 지리적 복제를 사용으로 설정한 경우 이 요소를 false로 설정하여 지리적 복제를 사용하지 않도록 선택할 수 있습니다. 사용 안 함으로 설정되면 데이터가 더 이상 보조 데이터 센터에 복제되지 않고 보조 위치의 데이터가 제거됩니다. 지리적 복제를 사용 안 함으로 설정한 후 이를 사용으로 설정하면 현재 데이터 복사본을 보조 데이터 센터에 복제하기 위한 저장소 계정이 청구됩니다. 데이터의 기존 복사본이 보조 데이터 센터로 복제된 후에는 추가 요금 청구 없이 업데이트가 지리적으로 복제됩니다.

 GeoReplicationEnabled 요소는 버전 2012-03-01을 사용 하 여 사용할 수 있는 이상 에서만 및는 2014-06-01 버전은 AccountType 요소로 대체 이후인 경우.
ExtendedProperties 저장소 계정에 추가된 확장된 속성의 이름 및 값을 지정합니다.
CustomDomains 저장소 계정과 연결된 사용자 지정 도메인을 지정합니다.

 CustomDomains 요소는 버전 2013-06-01을 사용 하 여 사용할 수 있는 이상 에서만.
SecondaryReadEnabled 저장소 계정에 대해 보조 읽기가 설정되어 있음을 나타냅니다.

가능한 값은 다음과 같습니다.

- true
- false

 SecondaryReadEnabled 요소는 버전 2013-11-01을 사용 하 여 사용할 수 있는 이상 에서만 및는 2014-06-01 버전은 AccountType 요소로 대체 이후인 경우.
AccountType 계정이 로컬 중복 저장소, 지역 중복 저장소 또는 읽기 권한의 지역 중복 저장소를 지원하는지 여부를 지정합니다. 저장소 계정을 업데이트할 경우 영역 중복 저장소는 옵션이 아닙니다.

가능한 값은 다음과 같습니다.

- Standard_LRS
- Standard_GRS
- Standard_RAGRS

 AccountType 요소는 사용할 버전 2014-06-01 이상 에서만 및 SecondaryReadEnabled 및 GeoReplicationEnabled 요소를 대체 합니다. Note:  Standard_ZRSPremium_LRS 계정 유형 옵션에 없으면 해당 계정을 다른 계정 유형으로 변경할 수 없으므로 합니다. 또한 다른 모든 계정 유형을 변경할 수 없습니다 Standard_ZRS 또는 Premium_LRS합니다.

ExtendedProperties

저장소 계정에 추가된 확장된 속성의 이름 및 값을 지정합니다.

요소 이름 설명
Name 선택 사항입니다. 확장 저장소 계정 속성의 이름을 나타냅니다. 각 확장 속성에는 정의된 이름과 값이 모두 있어야 합니다. 확장 속성 이름/값 쌍은 50개까지 지정할 수 있습니다.

Name 요소의 최대 길이는 64자이고, 영숫자와 밑줄만 포함할 수 있으며, 문자로 시작해야 합니다. Name에 다른 문자를 사용하거나, Name을 문자로 시작하지 않거나, 동일한 저장소 계정에서 소유하고 있는 다른 확장 속성의 이름과 동일한 이름을 입력하면 상태 코드 400(잘못된 요청) 오류가 반환됩니다.

 Name 요소는 버전 2012-03-01을 사용 하 여 사용할 수 있는 이상 에서만.
선택 사항입니다. 확장 저장소 계정 속성의 값을 나타냅니다. 각 확장 속성에는 정의된 이름과 값이 모두 있어야 합니다. 확장 속성 이름/값 쌍은 50개까지 지정할 수 있으며 각 확장 속성 값의 최대 길이는 255자입니다.

 Value 요소는 버전 2012-03-01을 사용 하 여 사용할 수 있는 이상 에서만.

CustomDomains

저장소 계정과 연결된 사용자 지정 도메인을 지정합니다.

요소 이름 설명
CustomDomain 저장소 계정과 연결된 사용자 지정 도메인에 대한 정보를 지정합니다.
Name 사용자 지정 도메인의 이름을 지정합니다.
UseSubDomainName 간접 CName 유효성 검사를 사용할 수 있는지 여부를 나타냅니다.

가능한 값은 다음과 같습니다.

- true
- false

응답

응답에는 HTTP 상태 코드, 응답 헤더 집합 및 응답 본문이 포함되어 있습니다.

상태 코드

작업에 성공하면 상태 코드 200(정상)이 반환됩니다. 상태 코드에 대 한 정보를 참조 하십시오. 서비스 관리 상태 및 오류 코드.

응답 헤더

이 작업의 응답에는 다음과 같은 헤더가 포함됩니다. 응답에는 추가 표준 HTTP 헤더가 포함될 수도 있습니다. 모든 표준 헤더를 준수 하는 HTTP/1.1 프로토콜 사양.

응답 헤더 설명
x-ms-request-id 관리 서비스에 대해 수행된 요청을 고유하게 식별하는 값입니다. 비동기 작업을 호출할 수 있습니다 작업 상태 가져오기 작업이 완료 되었는지 여부를 확인 하려면 헤더의 값, 실패 했는지, 또는 아직 진행중에서입니다.

응답 본문

없음.

설명

사용 하는 Update Storage Account 저장소 계정에 대 한 설명, 레이블 또는 지리적 복제 설정값을 변경 하는 작업입니다. 사용할 수는 저장소 계정 속성 가져오기 이러한 값을 검토 하는 작업입니다.

예제

다음 예제에서는 저장소 계정 속성 가져오기 저장소 계정에 대 한 초기 속성 값을 나열 하는 작업 업데이트는 LabelDescription 에 대 한 호출을 사용 하 여 속성의 Update Storage Account 작업을 호출 하 여 업데이트 된 결과 표시 합니다 저장소 계정 속성 가져오기합니다. 값을 변경 하는 Version 문자열을 원하는 버전의 Thumbprint 값에 대 한 관리 인증서 손도장 (thumbprint)는 SubscriptionId 중인 구독 식별자를 및 ServiceName 샘플을 실행 하려면 저장소 계정의 이름으로이 값.

namespace Microsoft.WindowsAzure.ServiceManagementRESTAPI.Samples { using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Net; using System.Security.Cryptography.X509Certificates; using System.Xml; using System.Xml.Linq; public class Program { // Set these constants with your values to run the sample. private const string Version = "2011-12-01"; private const string Thumbprint = "management-certificate-thumbprint"; private const string SubscriptionId = "subscription-identifier"; private const string ServiceName = "storage-account-name"; // This is the common namespace for all Service Management REST API XML data. private static XNamespace wa = "https://schemas.microsoft.com/windowsazure"; /// <summary> /// Gets or sets the certificate that matches the Thumbprint value. /// </summary> private static X509Certificate2 Certificate { get; set; } static void Main(string[] args) { try { Certificate = GetStoreCertificate(Thumbprint); // Get the initial property values for the storage account. // Convert the Label property to a readable value for display. XElement initialProperties = GetStorageAccountProperties(ServiceName); XElement labelElement = initialProperties.Descendants(wa + "Label").First(); labelElement.Value = labelElement.Value.FromBase64(); Console.WriteLine( "Storage Account Properties for {0}:{1}{2}", ServiceName, Environment.NewLine, initialProperties.ToString(SaveOptions.OmitDuplicateNamespaces)); // Update the label and description of the storage account. string label = String.Format("updated_{0}_label", ServiceName); string description = String.Format( "Updated description for {0}", ServiceName); UpdateStorageAccount(ServiceName, label, description, geoReplicationEnabled: false); // Get the updated property values for the storage account. // Convert the Label property to a readable value for display. XElement updatedProperties = GetStorageAccountProperties(ServiceName); labelElement = updatedProperties.Descendants(wa + "Label").First(); labelElement.Value = labelElement.Value.FromBase64(); Console.WriteLine( "Updated Storage Account Properties for {0}:{1}{2}", ServiceName, Environment.NewLine, updatedProperties.ToString(SaveOptions.OmitDuplicateNamespaces)); } catch (Exception ex) { Console.WriteLine("Exception caught in Main:"); Console.WriteLine(ex.Message); } Console.Write("Press any key to continue:"); Console.ReadKey(); } /// <summary> /// Calls the Get Storage Account Properties operation in the Service /// Management REST API for the specified subscription and storage account /// name and returns the StorageService XML element from the response. /// </summary> /// <param name="serviceName">The name of the storage account.</param> /// <returns>The StorageService XML element from the response.</returns> private static XElement GetStorageAccountProperties( string serviceName) { string uriFormat = "https://management.core.windows.net/{0}" + "/services/storageservices/{1}"; Uri uri = new Uri(String.Format(uriFormat, SubscriptionId, serviceName)); XDocument responseBody; InvokeRequest(uri, "GET", HttpStatusCode.OK, null, out responseBody); return responseBody.Element(wa + "StorageService"); } /// <summary> /// Calls the Update Storage Account operation in the Service Management /// REST API for the specified subscription, storage account name, new /// description, label, and geo-replication enabled setting. /// </summary> /// <param name="serviceName">The name of the storage account to update.</param> /// <param name="label">The new label for the storage account.</param> /// <param name="description">The new description for the storage account.</param> /// <param name="geoReplicationEnabled">The new geo-replication setting, if applicable. /// This optional parameter defaults to null.</param> private static void UpdateStorageAccount( string serviceName, string label, string description, bool? geoReplicationEnabled = null) { string uriFormat = "https://management.core.windows.net/{0}" + "/services/storageservices/{1}"; Uri uri = new Uri(String.Format(uriFormat, SubscriptionId, serviceName)); XDocument requestBody = new XDocument( new XDeclaration("1.0", "UTF-8", "no"), new XElement( wa + "UpdateStorageServiceInput", new XElement(wa + "Description", description), new XElement(wa + "Label", label.ToBase64()))); // Add the GeoReplicationEnabled element if the version supports it. if ((geoReplicationEnabled != null) && (String.CompareOrdinal(Version, "2011-12-01") >= 0)) { requestBody.Element(wa + "UpdateStorageServiceInput").Add( new XElement( wa + "GeoReplicationEnabled", geoReplicationEnabled.ToString().ToLowerInvariant())); } XDocument responseBody; InvokeRequest(uri, "PUT", HttpStatusCode.OK, requestBody, out responseBody); } /// <summary> /// Gets the certificate matching the thumbprint from the local store. /// Throws an ArgumentException if a matching certificate is not found. /// </summary> /// <param name="thumbprint">The thumbprint of the certificate to find.</param> /// <returns>The certificate with the specified thumbprint.</returns> private static X509Certificate2 GetStoreCertificate(string thumbprint) { List<StoreLocation> locations = new List<StoreLocation> { StoreLocation.CurrentUser, StoreLocation.LocalMachine }; foreach (var location in locations) { X509Store store = new X509Store("My", location); try { store.Open(OpenFlags.ReadOnly | OpenFlags.OpenExistingOnly); X509Certificate2Collection certificates = store.Certificates.Find( X509FindType.FindByThumbprint, thumbprint, false); if (certificates.Count == 1) { return certificates[0]; } } finally { store.Close(); } } throw new ArgumentException(string.Format( "A Certificate with Thumbprint '{0}' could not be located.", thumbprint)); } /// <summary> /// A helper function to invoke a Service Management REST API operation. /// Throws an ApplicationException on unexpected status code results. /// </summary> /// <param name="uri">The URI of the operation to invoke using a web request.</param> /// <param name="method">The method of the web request, GET, PUT, POST, or DELETE.</param> /// <param name="expectedCode">The expected status code.</param> /// <param name="requestBody">The XML body to send with the web request. Use null to send no request body.</param> /// <param name="responseBody">The XML body returned by the request, if any.</param> /// <returns>The requestId returned by the operation.</returns> private static string InvokeRequest( Uri uri, string method, HttpStatusCode expectedCode, XDocument requestBody, out XDocument responseBody) { responseBody = null; string requestId = String.Empty; HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri); request.Method = method; request.Headers.Add("x-ms-Version", Version); request.ClientCertificates.Add(Certificate); request.ContentType = "application/xml"; if (requestBody != null) { using (Stream requestStream = request.GetRequestStream()) { using (StreamWriter streamWriter = new StreamWriter( requestStream, System.Text.UTF8Encoding.UTF8)) { requestBody.Save(streamWriter, SaveOptions.DisableFormatting); } } } HttpWebResponse response; HttpStatusCode statusCode = HttpStatusCode.Unused; try { response = (HttpWebResponse)request.GetResponse(); } catch (WebException ex) { // GetResponse throws a WebException for 4XX and 5XX status codes response = (HttpWebResponse)ex.Response; } try { statusCode = response.StatusCode; if (response.ContentLength > 0) { using (XmlReader reader = XmlReader.Create(response.GetResponseStream())) { responseBody = XDocument.Load(reader); } } if (response.Headers != null) { requestId = response.Headers["x-ms-request-id"]; } } finally { response.Close(); } if (!statusCode.Equals(expectedCode)) { throw new ApplicationException(string.Format( "Call to {0} returned an error:{1}Status Code: {2} ({3}):{1}{4}", uri.ToString(), Environment.NewLine, (int)statusCode, statusCode, responseBody.ToString(SaveOptions.OmitDuplicateNamespaces))); } return requestId; } } /// <summary> /// Helpful extension methods for converting strings to and from Base-64. /// </summary> public static class StringExtensions { /// <summary> /// Converts a UTF-8 string to a Base-64 version of the string. /// </summary> /// <param name="s">The string to convert to Base-64.</param> /// <returns>The Base-64 converted string.</returns> public static string ToBase64(this string s) { byte[] bytes = System.Text.Encoding.UTF8.GetBytes(s); return Convert.ToBase64String(bytes); } /// <summary> /// Converts a Base-64 encoded string to UTF-8. /// </summary> /// <param name="s">The string to convert from Base-64.</param> /// <returns>The converted UTF-8 string.</returns> public static string FromBase64(this string s) { byte[] bytes = Convert.FromBase64String(s); return System.Text.Encoding.UTF8.GetString(bytes); } } }  
  

예제 코드를 실행하면 다음과 유사한 예제 프로그램 출력이 생성됩니다.

Storage Account Properties for myexamplestorage1: <StorageService xmlns="https://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Url>https://management.core.windows.net/01234567-89ab-cdef-0123-456789abcdef/services/storageservices/myexamplestorage1</Url> <ServiceName>myexamplestorage1</ServiceName> <StorageServiceProperties> <Description>myexamplestorage1 description</Description> <Location>North Central US</Location> <Label>My Example Label</Label> <Status>Created</Status> <Endpoints> <Endpoint>http://myexamplestorage1.blob.core.windows.net/</Endpoint> <Endpoint>http://myexamplestorage1.queue.core.windows.net/</Endpoint> <Endpoint>http://myexamplestorage1.table.core.windows.net/</Endpoint> </Endpoints> <GeoReplicationEnabled>true</GeoReplicationEnabled> <GeoPrimaryRegion>usnorth</GeoPrimaryRegion> <StatusOfPrimary>Available</StatusOfPrimary> <GeoSecondaryRegion>ussouth</GeoSecondaryRegion> <StatusOfSecondary>Available</StatusOfSecondary> </StorageServiceProperties> </StorageService> Updated Storage Account Properties for myexamplestorage1: <StorageService xmlns="https://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"> <Url>https://management.core.windows.net/01234567-89ab-cdef-0123-456789abcdef/services/storageservices/myexamplestorage1</Url> <ServiceName>myexamplestorage1</ServiceName> <StorageServiceProperties> <Description>Updated description for myexamplestorage1</Description> <Location>North Central US</Location> <Label>updated_myexamplestorage1_label</Label> <Status>Created</Status> <Endpoints> <Endpoint>http://myexamplestorage1.blob.core.windows.net/</Endpoint> <Endpoint>http://myexamplestorage1.queue.core.windows.net/</Endpoint> <Endpoint>http://myexamplestorage1.table.core.windows.net/</Endpoint> </Endpoints> <GeoReplicationEnabled>false</GeoReplicationEnabled> </StorageServiceProperties> </StorageService> Press any key to continue:  

참고 항목

저장소 계정 속성 가져오기