Azure Stack Hub 存储开发工具入门Get started with Azure Stack Hub storage development tools

Azure Stack Hub 提供一组存储服务,包括 Blob、表和队列存储。Azure Stack Hub provides a set of storage services that includes blob, table, and queue storage.

使用本文作为使用 Azure Stack Hub 存储开发工具的入门指南。Use this article as a guide to get started using Azure Stack Hub storage development tools. 可以在对应的 Azure 存储教程中,找到更多的详细信息和示例代码。You can find more detailed information and sample code in corresponding Azure storage tutorials.

Note

Azure Stack Hub 存储和 Azure 存储之间存在一些差异,包括每个平台的特定要求。There are differences between Azure Stack Hub storage and Azure storage, including specific requirements for each platform. 例如,Azure Stack Hub 有特定的客户端库以及终结点后缀要求。For example, there are specific client libraries and endpoint suffix requirements for Azure Stack Hub. 有关详细信息,请参阅 Azure Stack Hub 存储:差异和注意事项For more information, see Azure Stack Hub storage: Differences and considerations.

Azure 客户端库Azure client libraries

对于存储客户端库,请了解与 REST API 兼容的版本。For the storage client libraries, be aware of the version that is compatible with the REST API. 还必须在代码中指定 Azure Stack Hub 终结点。You must also specify the Azure Stack Hub endpoint in your code.

1811 更新或更高版本1811 update or newer versions

客户端库Client library Azure Stack Hub 支持的版本Azure Stack Hub supported version 链接Link 终结点规范Endpoint specification
.NET.NET 9.2.09.2.0 Nuget 包:Nuget package:
https://www.nuget.org/packages/WindowsAzure.Storage/9.2.0

GitHub 版本:GitHub release:
https://github.com/Azure/azure-storage-net/releases/tag/v9.2.0
app.config 文件app.config file
JavaJava 7.0.07.0.0 Maven 包:Maven package:
https://mvnrepository.com/artifact/com.microsoft.azure/azure-storage/7.0.0

GitHub 版本:GitHub release:
https://github.com/Azure/azure-storage-java/releases/tag/v7.0.0
连接字符串设置Connection string setup
Node.jsNode.js 2.8.32.8.3 NPM 链接:NPM link:
https://www.npmjs.com/package/azure-storage
(运行:npm install azure-storage@2.8.3(Run: npm install azure-storage@2.8.3)

GitHub 版本:GitHub release:
https://github.com/Azure/azure-storage-node/releases/tag/v2.8.3
服务实例声明Service instance declaration
C++C++ 5.2.05.2.0 Nuget 包:Nuget package:
https://www.nuget.org/packages/Microsoft.Azure.Storage.CPP.v140/5.2.0

GitHub 版本:GitHub release:
https://github.com/Azure/azure-storage-cpp/releases/tag/v5.2.0
连接字符串设置Connection string setup
PHPPHP 1.2.01.2.0 GitHub 版本:GitHub release:
常见:https://github.com/Azure/azure-storage-php/releases/tag/v1.2.0-commonCommon: https://github.com/Azure/azure-storage-php/releases/tag/v1.2.0-common
Blob:https://github.com/Azure/azure-storage-php/releases/tag/v1.2.0-blobBlob: https://github.com/Azure/azure-storage-php/releases/tag/v1.2.0-blob
队列:Queue:
https://github.com/Azure/azure-storage-php/releases/tag/v1.1.1-queue
表:https://github.com/Azure/azure-storage-php/releases/tag/v1.1.0-tableTable: https://github.com/Azure/azure-storage-php/releases/tag/v1.1.0-table

通过编辑器进行安装(若要了解更多内容,请参阅下面的详细信息。)Install via Composer (To learn more, see the details below.)
连接字符串设置Connection string setup
PythonPython 1.1.01.1.0 GitHub 版本:GitHub release:
常见:Common:
https://github.com/Azure/azure-storage-python/releases/tag/v1.1.0-common
Blob:Blob:
https://github.com/Azure/azure-storage-python/releases/tag/v1.1.0-blob
队列:Queue:
https://github.com/Azure/azure-storage-python/releases/tag/v1.1.0-queue
服务实例声明Service instance declaration
RubyRuby 1.0.11.0.1 RubyGems 包:RubyGems package:
常见:Common:
https://rubygems.org/gems/azure-storage-common/versions/1.0.1
Blob:https://rubygems.org/gems/azure-storage-blob/versions/1.0.1Blob: https://rubygems.org/gems/azure-storage-blob/versions/1.0.1
队列:https://rubygems.org/gems/azure-storage-queue/versions/1.0.1Queue: https://rubygems.org/gems/azure-storage-queue/versions/1.0.1
表:https://rubygems.org/gems/azure-storage-table/versions/1.0.1Table: https://rubygems.org/gems/azure-storage-table/versions/1.0.1

GitHub 版本:GitHub release:
常见:https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-commonCommon: https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-common
Blob:https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-blobBlob: https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-blob
队列:https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-queueQueue: https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-queue
表:https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-tableTable: https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-table
连接字符串设置Connection string setup

通过编辑器安装 PHP 客户端 - 当前Install PHP client via Composer - current

若要通过编辑器进行安装,请执行以下操作(以 Blob 为例):To install via Composer: (take the blob as an example).

  1. 在项目的根目录中,使用以下代码创建一个名为 composer.json 的文件:Create a file named composer.json in the root of the project with following code:

    {
      "require": {
      "Microsoft/azure-storage-blob":"1.2.0"
      }
    }
    
  2. composer.phar 下载到项目根目录。Download composer.phar to the project root.

  3. 运行:php composer.phar installRun: php composer.phar install.

以前的版本(1802 到 1809 更新)Previous versions (1802 to 1809 update)

客户端库Client library Azure Stack Hub 支持的版本Azure Stack Hub supported version 链接Link 终结点规范Endpoint specification
.NET.NET 8.7.08.7.0 Nuget 包:Nuget package:
https://www.nuget.org/packages/WindowsAzure.Storage/8.7.0

GitHub 版本:GitHub release:
https://github.com/Azure/azure-storage-net/releases/tag/v8.7.0
app.config 文件app.config file
JavaJava 6.1.06.1.0 Maven 包:Maven package:
https://mvnrepository.com/artifact/com.microsoft.azure/azure-storage/6.1.0

GitHub 版本:GitHub release:
https://github.com/Azure/azure-storage-java/releases/tag/v6.1.0
连接字符串设置Connection string setup
Node.jsNode.js 2.7.02.7.0 NPM 链接:NPM link:
https://www.npmjs.com/package/azure-storage
(运行:npm install azure-storage@2.7.0(Run: npm install azure-storage@2.7.0)

GitHub 版本:GitHub release:
https://github.com/Azure/azure-storage-node/releases/tag/v2.7.0
服务实例声明Service instance declaration
C++C++ 3.1.03.1.0 Nuget 包:Nuget package:
https://www.nuget.org/packages/wastorage.v140/3.1.0

GitHub 版本:GitHub release:
https://github.com/Azure/azure-storage-cpp/releases/tag/v3.1.0
连接字符串设置Connection string setup
PHPPHP 1.0.01.0.0 GitHub 版本:GitHub release:
常见:https://github.com/Azure/azure-storage-php/releases/tag/v1.0.0-commonCommon: https://github.com/Azure/azure-storage-php/releases/tag/v1.0.0-common
Blob:https://github.com/Azure/azure-storage-php/releases/tag/v1.0.0-blobBlob: https://github.com/Azure/azure-storage-php/releases/tag/v1.0.0-blob
队列:Queue:
https://github.com/Azure/azure-storage-php/releases/tag/v1.0.0-queue
表:https://github.com/Azure/azure-storage-php/releases/tag/v1.0.0-tableTable: https://github.com/Azure/azure-storage-php/releases/tag/v1.0.0-table

通过编辑器安装(请参阅下面的详细信息)。Install via Composer (see the details below).)
连接字符串设置Connection string setup
PythonPython 1.0.01.0.0 GitHub 版本:GitHub release:
常见:Common:
https://github.com/Azure/azure-storage-python/releases/tag/v1.0.0-common
Blob:Blob:
https://github.com/Azure/azure-storage-python/releases/tag/v1.0.0-blob
队列:Queue:
https://github.com/Azure/azure-storage-python/releases/tag/v1.0.0-queue
服务实例声明Service instance declaration
RubyRuby 1.0.11.0.1 RubyGems 包:RubyGems package:
常见:Common:
https://rubygems.org/gems/azure-storage-common/versions/1.0.1
Blob:https://rubygems.org/gems/azure-storage-blob/versions/1.0.1Blob: https://rubygems.org/gems/azure-storage-blob/versions/1.0.1
队列:https://rubygems.org/gems/azure-storage-queue/versions/1.0.1Queue: https://rubygems.org/gems/azure-storage-queue/versions/1.0.1
表:https://rubygems.org/gems/azure-storage-table/versions/1.0.1Table: https://rubygems.org/gems/azure-storage-table/versions/1.0.1

GitHub 版本:GitHub release:
常见:https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-commonCommon: https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-common
Blob:https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-blobBlob: https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-blob
队列:https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-queueQueue: https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-queue
表:https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-tableTable: https://github.com/Azure/azure-storage-ruby/releases/tag/v1.0.1-table
连接字符串设置Connection string setup

通过编辑器安装 PHP 客户端 - 以前Install PHP client via Composer - previous

若要通过编辑器进行安装,请执行以下操作(以 Blob 为例):To install via Composer: (take blob as example).

  1. 在项目的根目录中,使用以下代码创建一个名为 composer.json 的文件:Create a file named composer.json in the root of the project with following code:

     {
       "require": {
       "Microsoft/azure-storage-blob":"1.0.0"
       }
     }
    
  2. composer.phar 下载到项目根目录。Download composer.phar to the project root.

  3. 运行:php composer.phar installRun: php composer.phar install.

终结点声明Endpoint declaration

Azure Stack Hub 终结点包含两个部分:区域的名称和 Azure Stack Hub 域。An Azure Stack Hub endpoint includes two parts: the name of a region and the Azure Stack Hub domain. 在 Azure Stack 开发工具包中,默认终结点是 local.azurestack.externalIn the Azure Stack Development Kit, the default endpoint is local.azurestack.external. 如果不确定你的终结点,请与云管理员联系。Contact your cloud admin if you're not sure about your endpoint.

示例Examples

.NET.NET

对于 Azure Stack Hub,在 app.config 文件中指定终结点后缀:For Azure Stack Hub, the endpoint suffix is specified in the app.config file:

<add key="StorageConnectionString"
value="DefaultEndpointsProtocol=https;AccountName=myaccount;AccountKey=mykey;
EndpointSuffix=local.azurestack.external;" />

JavaJava

对于 Azure Stack Hub,在连接字符串的设置中指定终结点后缀:For Azure Stack Hub, the endpoint suffix is specified in the setup of connection string:

public static final String storageConnectionString =
    "DefaultEndpointsProtocol=http;" +
    "AccountName=your_storage_account;" +
    "AccountKey=your_storage_account_key;" +
    "EndpointSuffix=local.azurestack.external";

Node.jsNode.js

对于 Azure Stack Hub,在声明实例中指定终结点后缀:For Azure Stack Hub, the endpoint suffix is specified in the declaration instance:

var blobSvc = azure.createBlobService('myaccount', 'mykey',
'myaccount.blob.local.azurestack.external');

C++C++

对于 Azure Stack Hub,在连接字符串的设置中指定终结点后缀:For Azure Stack Hub, the endpoint suffix is specified in the setup of connection string:

const utility::string_t storage_connection_string(U("DefaultEndpointsProtocol=https;
AccountName=your_storage_account;
AccountKey=your_storage_account_key;
EndpointSuffix=local.azurestack.external"));

PHPPHP

对于 Azure Stack Hub,在连接字符串的设置中指定终结点后缀:For Azure Stack Hub, the endpoint suffix is specified in the setup of connection string:

$connectionString = 'BlobEndpoint=https://<storage account name>.blob.local.azurestack.external/;
QueueEndpoint=https:// <storage account name>.queue.local.azurestack.external/;
TableEndpoint=https:// <storage account name>.table.local.azurestack.external/;
AccountName=<storage account name>;AccountKey=<storage account key>'

PythonPython

对于 Azure Stack Hub,在声明实例中指定终结点后缀:For Azure Stack Hub, the endpoint suffix is specified in the declaration instance:

block_blob_service = BlockBlobService(account_name='myaccount',
account_key='mykey',
endpoint_suffix='local.azurestack.external')

RubyRuby

对于 Azure Stack Hub,在连接字符串的设置中指定终结点后缀:For Azure Stack Hub, the endpoint suffix is specified in the setup of connection string:

set
AZURE_STORAGE_CONNECTION_STRING=DefaultEndpointsProtocol=https;
AccountName=myaccount;
AccountKey=mykey;
EndpointSuffix=local.azurestack.external

Blob 存储Blob storage

以下 Azure Blob 存储教程适用于 Azure Stack Hub。The following Azure Blob storage tutorials are applicable to Azure Stack Hub. 请注意前面示例部分中所述的 Azure Stack Hub 特定终结点后缀需求。Note the specific endpoint suffix requirement for Azure Stack Hub described in the previous Examples section.

队列存储Queue storage

以下 Azure 队列存储教程适用于 Azure Stack Hub。The following Azure Queue storage tutorials are applicable to Azure Stack Hub. 请注意前面示例部分中所述的 Azure Stack Hub 特定终结点后缀需求。Note the specific endpoint suffix requirement for Azure Stack Hub described in the previous Examples section.

表存储Table storage

以下 Azure 表存储教程适用于 Azure Stack Hub。The following Azure Table storage tutorials are applicable to Azure Stack Hub. 请注意前面示例部分中所述的 Azure Stack Hub 特定终结点后缀需求。Note the specific endpoint suffix requirement for Azure Stack Hub described in the previous Examples section.

后续步骤Next steps