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.
备注
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.
2008 更新2008 update
通过 Composer 安装 PHP 客户端 - 当前Install PHP client via Composer - current
若要通过编辑器进行安装,请执行以下操作(以 Blob 为例):To install via Composer: (take the blob as an example).
在项目的根目录中,使用以下代码创建一个名为 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" } }
将 composer.phar 下载到项目根目录。Download composer.phar to the project root.
运行:
php composer.phar install
。Run:php composer.phar install
.
2005 更新2005 update
通过 Composer 安装 PHP 客户端 - 当前Install PHP client via Composer - current
若要通过编辑器进行安装,请执行以下操作(以 Blob 为例):To install via Composer: (take the blob as an example).
在项目的根目录中,使用以下代码创建一个名为 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" } }
将 composer.phar 下载到项目根目录。Download composer.phar to the project root.
运行:
php composer.phar install
。Run:php composer.phar install
.
以前的版本(1811 到 2002 更新)Previous versions (1811 to 2002 update)
通过 Composer 安装 PHP 客户端 - 当前Install PHP client via Composer - current
若要通过编辑器进行安装,请执行以下操作(以 Blob 为例):To install via Composer: (take the blob as an example).
在项目的根目录中,使用以下代码创建一个名为 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" } }
将 composer.phar 下载到项目根目录。Download composer.phar to the project root.
运行:
php composer.phar install
。Run:php composer.phar install
.
以前的版本(1802 到 1809 更新)Previous versions (1802 to 1809 update)
通过编辑器安装 PHP 客户端 - 以前Install PHP client via Composer - previous
通过 Composer 安装:(以 blob 为例)。To install via Composer: (take blob as example).
在项目的根目录中,使用以下代码创建一个名为 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" } }
将 composer.phar 下载到项目根目录。Download composer.phar to the project root.
运行:
php composer.phar install
。Run: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.external。In 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.
- 通过 .NET 开始使用 Azure Blob 存储Get started with Azure Blob storage using .NET
- 如何通过 Java 使用 Blob 存储How to use Blob storage from Java
- 如何通过 Node.js 使用 Blob 存储How to use Blob storage from Node.js
- 如何通过 C++ 使用 Blob 存储How to use Blob storage from C++
- 如何通过 PHP 使用 Blob 存储How to use Blob storage from PHP
- 如何通过 Python 使用 Azure Blob 存储How to use Azure Blob storage from Python
- 如何通过 Ruby 使用 Blob 存储How to use Blob storage from Ruby
队列存储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.
- 通过 .NET 开始使用 Azure 队列存储Get started with Azure Queue storage using .NET
- 如何通过 Java 使用队列存储How to use Queue storage from Java
- 如何通过 Node.js 使用队列存储How to use Queue storage from Node.js
- 如何通过 C++ 使用队列存储How to use Queue storage from C++
- 如何通过 PHP 使用队列存储How to use Queue storage from PHP
- 如何通过 Python 使用队列存储How to use Queue storage from Python
- 如何通过 Ruby 使用队列存储How to use Queue storage from Ruby
表存储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.
- 通过 .NET 开始使用 Azure 表存储Get started with Azure Table storage using .NET
- 如何通过 Java 使用表存储How to use Table storage from Java
- 如何通过 Node.js 使用 Azure 表存储How to use Azure Table storage from Node.js
- 如何通过 C++ 使用表存储How to use Table storage from C++
- 如何通过 PHP 使用表存储How to use Table storage from PHP
- 如何在 Python 中使用表存储How to use Table storage in Python
- 如何通过 Ruby 使用表存储How to use Table storage from Ruby