Eksporter (0) Skriv ut
Vis alt
EN
Dette innholdet er ikke tilgjengelig på ditt språk, men her er den engelske versjonen.

List Storage Accounts

Updated: October 22, 2014

The List Storage Accounts operation lists the storage accounts that are available in the specified subscription.

The List Storage Accounts request may be specified as follows. Replace <subscription-id> with your subscription ID.

 

Method Request URI

GET

https://management.core.windows.net/<subscription-id>/services/storageservices

You must make sure that the request that is made to the management service is secure. For additional details, see Authenticating Service Management Requests.

The following table describes the request headers.

 

Request Header Description

x-ms-version

Required. Specifies the version of the operation to use for this request. This header should be set to 2009-10-01 or higher. For more information about versioning headers, see Service Management Versioning.

The response includes an HTTP status code, a set of response headers, and a response body.

A successful operation returns status code 200 (OK).

For information about status codes, see Service Management Status and Error Codes.

The response for this operation includes the following headers. The response may also include additional standard HTTP headers. All standard headers conform to the HTTP/1.1 protocol specification.

 

Response Header Description

x-ms-request-id

A value that uniquely identifies a request made against the management service.

The format of the response body is as follows:


<?xml version="1.0" encoding="utf-8"?>
  <StorageServices xmlns=”http://schemas.microsoft.com/windowsazure”>
    <StorageService>
      <Url>storage-service-address</Url>
      <ServiceName>storage-service-name</ServiceName>
      <StorageServiceProperties>
        <Description>description</Description>
        <AffinityGroup>affinity-group</AffinityGroup>
        <Location>location-of-storage-account</Location>
        <Label>base64-encoded-label</Label>
        <Status>status</Status>
        <Endpoints>
          <Endpoint>storage-service-blob-endpoint</Endpoint>
          <Endpoint>storage-service-queue-endpoint</Endpoint>
          <Endpoint>storage-service-table-endpoint</Endpoint>
          <Endpoint>storage-service-file-endpoint</Endpoint>
        </Endpoints>
        <GeoReplicationEnabled>geo-replication-indicator</GeoReplicationEnabled>
        <GeoPrimaryRegion>primary-region</GeoPrimaryRegion>
        <StatusOfPrimary>primary-status</StatusOfPrimary>
        <LastGeoFailoverTime>DateTime</LastGeoFailoverTime>
        <GeoSecondaryRegion>secondary-region</GeoSecondaryRegion>
        <StatusOfSecondary>secondary-status</StatusOfSecondary>
        <CreationTime>time-of-creation</CreationTime>
        <CustomDomains>
          <CustomDomain>
            <Name>name-of-custom-domain</Name>
          </CustomDomain>
        </CustomDomains>
        <SecondaryReadEnabled>secondary-read-indicator</SecondaryReadEnabled>
        <SecondaryEndpoints>
          <Endpoint>storage-secondary-service-blob-endpoint</Endpoint>
          <Endpoint>storage-secondary-service-queue-endpoint</Endpoint>
          <Endpoint>storage-secondary-service-table-endpoint</Endpoint>
        </SecondaryEndpoints>
        <AccountType>type-of-storage-account</AccountType>
      </StorageServiceProperties>
      <ExtendedProperties>
        <ExtendedProperty>
          <Name>property-name</Name>
          <Value>property-value</Value>
        </ExtendedProperty>
      </ExtendedProperties>
    </StorageService>
  </StorageServices>

The following table describes the elements of the response body.

 

Element name Description

Url

Specifies the URI of the storage account.

ServiceName

Specifies the name of the storage account. This name is the DNS prefix name and can be used to access blobs, queues, and tables in the storage account.

For example, if the service name is MyStorageAccount you could access the blob containers by calling: http://MyStorageAccount.blob.core.windows.net/mycontainer/

StorageServiceProperties

Specifies the properties of the storage account.

ExtendedProperties

Specifies the name and value of an extended property that was added to the storage account.

Specifies the properties of the storage account.

 

Element name Description

Description

Optional. A description for the storage account. The description can be up to 1024 characters in length.

The Description element is only available using version 2012-03-01 or higher.

AffinityGroup

Required if Location is not specified. The name of an existing affinity group associated with this subscription. This name is a GUID and can be retrieved by examining the name element of the response body returned by the List Affinity Groups operation.

The AffinityGroup element is only available using version 2012-03-01 or higher.

Location

Required if AffinityGroup is not specified. The location where the storage account will be created.

The Location element is only available using version 2012-03-01 or higher.

Label

Required. A name for the hosted service that is base-64 encoded. The name can be up to 100 characters in length. The name can be used identify the storage account for your tracking purposes.

The Label element is only available using version 2012-03-01 or higher.

Status

The status of the storage account. Possible values are:

  • Creating

  • Created

  • Deleting

  • Deleted

  • Changing

  • ResolvingDns

The Status element is only available using version 2012-03-01 or higher.

Endpoints

The blob, table, queue, and file endpoints.

Note1: The file endpoint is in preview mode and will only be returned for preview-enabled subscriptions.

Also note that Note 2: for the Standard_ZRS account type, only the blob endpoint is returned. ZRS also only supports block blobs, not page blobs, and is therefore not compatible with IaaS VMs.

Note 3: For the Premium_LRS account type, only the blob endpoint is returned.

GeoReplicationEnabled

Indicates whether the data in the storage account is replicated across more than one geographic location so as to enable resilience in the face of catastrophic service loss. The value is true if geo-replication is enabled; otherwise false.

The GeoReplicationEnabled element is only available using version 2012-03-01 or higher and is replaced by the AccountType element with version 2014-06-01 or higher.

GeoPrimaryRegion

Indicates the primary geographical region in which the storage account exists at this time.

The GeoPrimaryRegion element is only available using version 2012-03-01 or higher.

StatusOfPrimary

Indicates whether the primary storage region is available.

Possible values are:

  • Available

  • Unavailable

The StatusOfPrimary element is only available using version 2013-11-01 or higher.

LastGeoFailoverTime

A timestamp that indicates the most recent instance of a failover to the secondary region. In case of multiple failovers only the latest failover date and time maintained.

The format of the returned timestamp is: [4DigitYear]-[2DigitMonth]-[2DigitDay]T[2DigitMinute]:[2DigitSecond]:[7DigitsOfPrecision]Z

For example: <LastGeoFailoverTime>2010-01-18T13:15:30.0000000Z</LastGeoFailoverTime>

LastGeoFailoverTime is not returned if there has not been an instance of a failover.

The LastGeoFailoverTime element is only available using version 2012-03-01 or higher.

GeoSecondaryRegion

Indicates the geographical region in which the storage account is being replicated.

The GeoSecondaryRegion element is not returned if geo-replication is “off” for this account.

The GeoSecondaryRegion element is only available using version 2012-03-01 or higher.

StatusOfSecondary

Indicates whether the secondary storage region is available.

The StatusOfSecondary element is only available using version 2013-11-01 or higher.

Possible values are:

  • Available

  • Unavailable

CreationTime

Specifies the time that the storage account was created.

CustomDomains

Specifies the custom domains that are associated with the storage account.

The CustomDomains element is only available using version 2013-06-01 or higher.

SecondaryReadEnabled

Indicates that secondary read is enabled for the storage account.

Possible values are:

  • true

  • false

The SecondaryReadEnabled element is only available using version 2013-11-01 or higher and is replaced by the AccountType element with version 2014-06-01 or higher.

SecondaryEndpoints

Specifies the secondary endpoints of the storage account.

The SecondaryEndpoints element is only available using version 2013-11-01 or higher.

AccountType

Specifies whether the account supports locally-redundant storage, geo-redundant storage, zone-redundant storage, or read access geo-redundant storage.

Possible values are:

  • Standard_LRS

  • Standard_ZRS

  • Standard_GRS

  • Standard_RAGRS

  • Premium_LRS

The AccountType element is only available using version 2014-06-01 or higher and it replaces the SecondaryReadEnabled and GeoReplicationEnabled elements.

The Premium_LRS element is only available using version 21014-10-01 or higher.

Specifies the endpoints of the storage account.

 

Element name Description

Endpoint

Contains the blob service endpoint in the following format: https://<storage-service-name>.blob.core.windows.net

The Endpoint element is only available using version 2012-03-01 or higher. Http endpoints, are returned with version 2014-04-01 or lower.

Endpoint

Contains the queue service endpoint in the following format: https://<storage-service-name>.queue.core.windows.net

The Endpoint element is only available using version 2012-03-01 or higher. Http endpoints, are returned with version 2014-04-01 or lower.

Endpoint

Contains the table service endpoint in the following format: https://<storage-service-name>.table.core.windows.net

The Endpoint element is only available using version 2012-03-01 or higher. Http endpoints, are returned with version 2014-04-01 or lower.

Endpoint

Contains the file service endpoint in the following format: https://<storage-service-name>.file.core.windows.net

The Endpoint element is only available using version 2012-03-01 or higher. Http endpoints, are returned with version 2014-04-01 or lower.

Specifies the custom domains that are associated with the storage account.

 

Element name Description

CustomDomain

Specifies information about a custom domain that is associated with the storage account.

Name

Specifies the name of the custom domain.

Specifies the secondary endpoints of the storage account.

 

Element name Description

Endpoint

Contains the blob secondary service endpoint in the following format: https://<storage-secondary-service-name>.blob.core.windows.net

Http endpoints, are returned with version 2014-04-01 or lower.

Endpoint

Contains the queue service endpoint in the following format: https://<storage-secondary-service-name>.queue.core.windows.net

Http endpoints, are returned with version 2014-04-01 or lower.

Endpoint

Contains the table service endpoint in the following format: https://<storage-secondary-service-name>.table.core.windows.net

Http endpoints, are returned with version 2014-04-01 or lower.

Specifies the name and value of an extended property that was added to the storage account.

 

Element name Description

Name

Optional. Represents the name of an extended storage account property. Each extended property must have both a defined name and value. You can have a maximum of 50 extended property name/value pairs.

The maximum length of the Name element is 64 characters, only alphanumeric characters and underscores are valid in the Name, and the name must start with a letter. Attempting to use other characters, starting the Name with a non-letter character, or entering a name that is identical to that of another extended property owned by the same storage account, will result in a status code 400 (Bad Request) error.

The Name element is only available using version 2012-03-01 or higher.

Value

Optional. Represents the value of an extended storage account property. Each extended property must have both a defined name and value. You can have a maximum of 50 extended property name/value pairs, and each extended property value has a maximum length of 255 characters.

The Value element is only available using version 2012-03-01 or higher.

If the x-ms-version is 2012-03-01 or later and the affinity group was created in one of the deprecated Anywhere US, Anywhere Europe, Anywhere Asia regions, the Location element will return the location where this affinity group is now allocated.

The List Storage Accounts operation can be used to obtain the URIs to use for other operations on storage accounts, such as Get Storage Account Properties, Get Storage Account Keys, Delete Storage Account, and Update Storage Account.

The following example program takes the subscription ID, an associated management certificate thumbprint, and the operation version string, and prints the list of storage accounts to the console. Initialize the msVersion, subscriptionId, and thumbprint variables with your own values to run the example code. This example uses x-ms-version 2011-10-01.

using System;
using System.Collections.Generic;
using System.Net;
using System.Security.Cryptography.X509Certificates;
using System.Xml;
using System.Xml.Linq;
 
class Program
{
  static void Main(string[] args)
  {
    string msVersion = "2011-10-01";
    string subscriptionId = "subscription-id-guid";
    string thumbprint = "certificate-thumbprint";
    try
    {
      // Obtain the certificate with the specified thumbprint
      X509Certificate2 certificate = GetCertificate(thumbprint);
      ListStorageAccountsExample(subscriptionId, certificate, msVersion);
    }
    catch (Exception ex)
    {
      Console.WriteLine("Exception caught in Main:");
      Console.WriteLine(ex.Message);
    }
  }
 
  public static X509Certificate2 GetCertificate(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));
  }
 
  public static void ListStorageAccountsExample(
    string subscriptionId,
    X509Certificate2 certificate,
    string version)
  {
    string uriFormat = "https://management.core.windows.net/{0}/services/storageservices";
    Uri uri = new Uri(String.Format(uriFormat, subscriptionId));
 
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);
    request.Method = "GET";
    request.Headers.Add("x-ms-version", version);
    request.ClientCertificates.Add(certificate);
    request.ContentType = "application/xml";
 
    XDocument responseBody = null;
    HttpStatusCode statusCode;
    HttpWebResponse response;
    try
    {
      response = (HttpWebResponse)request.GetResponse();
    }
    catch (WebException ex)
    {
      // GetResponse throws a WebException for 400 and 500 status codes
      response = (HttpWebResponse)ex.Response;
    }
    statusCode = response.StatusCode;
    if (response.ContentLength > 0)
    {
      using (XmlReader reader = XmlReader.Create(response.GetResponseStream()))
      {
        responseBody = XDocument.Load(reader);
      }
    }
    response.Close();
    if (statusCode.Equals(HttpStatusCode.OK))
    {
      XNamespace wa = "http://schemas.microsoft.com/windowsazure";
      XElement storageServices = responseBody.Element(wa + "StorageServices");
      int storageCount = 0;
      foreach (XElement storageService in storageServices.Elements(wa + "StorageService"))
      {
        string url = storageService.Element(wa + "Url").Value;
        string serviceName = storageService.Element(wa + "ServiceName").Value;
        Console.WriteLine(
          "Location[{0}]{1}  Name: {2}{1}  DisplayName: {3}",
          storageCount++, Environment.NewLine, url, serviceName);
      }
    }
    else
    {
      Console.WriteLine("Call to List Storage Accounts returned an error:");
      Console.WriteLine("Status Code: {0} ({1}):{2}{3}",
        (int)statusCode, statusCode, Environment.NewLine,
        responseBody.ToString(SaveOptions.OmitDuplicateNamespaces));
    }
    return;
  }
}

Vis:
© 2014 Microsoft