開始使用 Azure Stack Hub 儲存體開發工具

Microsoft Azure Stack Hub 提供一組儲存體服務,包括 Blob、資料表和佇列儲存體。

使用本文作為開始使用 Azure Stack Hub 儲存體開發工具的指南。 您可以在對應的 Azure 儲存體教學課程中,找到更詳細的資訊和範例程式碼。

注意

Azure Stack Hub 儲存體與 Azure 儲存體之間有一些差異,包括每個平台的特定需求。 例如,Azure Stack Hub 有特定的用戶端程式庫和端點尾碼需求。 如需詳細資訊,請參閱 Azure Stack Hub 儲存體:差異與注意事項

Azure 用戶端程式庫

對於儲存體用戶端程式庫,請留意與 REST API 相容的版本。 您也必須在程式碼中指定 Azure Stack Hub 端點。

2301 更新和更新版本

用戶端程式庫 Azure Stack Hub 支援的版本 連結 端點規格
.NET Common: 12.9.0
Blob:12.10.0
佇列:12.8.0
Nuget 套件:
一般:https://www.nuget.org/packages/Azure.Storage.common/12.9.0
Blob:https://www.nuget.org/packages/Azure.Storage.Blobs/12.10.0
佇列:https://www.nuget.org/packages/Azure.Storage.queues/12.8.0

GitHub 版本:
一般:https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.9.0/sdk/storage/Azure.Storage.Common
Blob:https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.10.0/sdk/storage/Azure.Storage.Blobs
佇列:https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.8.0/sdk/storage/Azure.Storage.Queues
app.config 檔案
Java Common: 12.12.0
Blob:12.14.3
佇列:12.11.3
Maven 套件:
一般:https://mvnrepository.com/artifact/com.azure/azure-storage-common/12.12.0
Blob:https://mvnrepository.com/artifact/com.azure/azure-storage-blob/12.14.3
佇列:https://mvnrepository.com/artifact/com.azure/azure-storage-queue/12.11.3

GitHub 版本:
一般:https://github.com/Azure/azure-sdk-for-java/tree/azure-storage-common_12.12.0/sdk/storage/azure-storage-common
Blob:https://github.com/Azure/azure-sdk-for-java/tree/azure-storage-blob_12.14.3/sdk/storage/azure-storage-blob
佇列:https://github.com/Azure/azure-sdk-for-java/tree/azure-storage-queue_12.11.3/sdk/storage/azure-storage-queue
連接字串設定
Node.js 2.8.3 NPM 連結:
https://www.npmjs.com/package/azure-storage
(執行:npm install azure-storage@2.8.3)

GitHub 版本:
https://github.com/Azure/azure-storage-node/releases/tag/v2.8.3
服務執行個體宣告
C++ Blob:12.2.0
佇列:12.0.0
GitHub 版本:
Blob:https://github.com/Azure/azure-sdk-for-cpp/tree/azure-storage-blobs_12.2.0
佇列:https://github.com/Azure/azure-sdk-for-cpp/tree/azure-storage-queues_12.0.0
連接字串設定
PHP 1.2.0 GitHub 版本:
一般: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-blob
佇列:
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-table

透過編輯器安裝 (若要深入了解,請參閱以下詳細資料)。
連接字串設定
Python Blob:12.9.0
佇列:12.1.6
GitHub 版本:
Blob:
https://github.com/Azure/azure-sdk-for-python/tree/azure-storage-blob_12.9.0/sdk/storage/azure-storage-blob
佇列:
https://github.com/Azure/azure-sdk-for-python/tree/azure-storage-queue_12.1.6/sdk/storage/azure-storage-queue
服務執行個體宣告
Ruby 1.0.1 RubyGems 套件:
一般:
https://rubygems.org/gems/azure-storage-common/versions/1.0.1
Blob:https://rubygems.org/gems/azure-storage-blob/versions/1.0.1
佇列:https://rubygems.org/gems/azure-storage-queue/versions/1.0.1
資料表:https://rubygems.org/gems/azure-storage-table/versions/1.0.1

GitHub 版本:
一般: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-blob
佇列: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-table
連接字串設定

注意

因為易受攻擊版的 Jackson 套件相依性,所以舊版 .NET 和 Java 用戶端程式庫中有一個高嚴重性的弱點。 強烈建議使用支援的最新版 .NET 和 Java 用戶端程式庫版本,以避免發生安全性問題。

透過編輯器安裝 PHP 用戶端 - 目前

若要透過編輯器安裝:(以 Blob 為例)。

  1. 在專案的根目錄中,使用下列程式碼建立一個名為 composer.json 的檔案:

    {
      "require": {
      "Microsoft/azure-storage-blob":"1.2.0"
      }
    }
    
  2. composer.phar 下載到專案根目錄中。

  3. 執行:php composer.phar install

指定 API 版本

若要使用新的 .NET 用戶端程式庫 (一般:v12.9.0/Blob:v12.10.0/佇列:v12.8.0) 和 Java 用戶端程式庫 (一般:v12.12.0/Blob:v12.13.0/佇列:v12.10.0),您必須在每個用戶端類別中明確指定 serviceVersion (包括 BlobServiceClientBlobContainerClientBlobClientQueueServiceClientQueueClient),因為 Azure Stack Hub 目前不支援用戶端類別中的預設版本。

範例

.NET
BlobClientOptions options = new BlobClientOptions(BlobClientOptions.ServiceVersion.V2019_07_07);
BlobServiceClient client = new BlobServiceClient("<connection_string>", options);
Java
BlobServiceVersion version = BlobServiceVersion.V2019_07_07; 
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
    .endpoint("<your_endpoint>")
    .sasToken("<your_SAS_token>")
    .serviceVersion(version)
    .buildClient();

2008 更新和更新版本

用戶端程式庫 Azure Stack Hub 支援的版本 連結 端點規格
.NET Common: 12.9.0
Blob:12.10.0
佇列:12.8.0
Nuget 套件:
一般:https://www.nuget.org/packages/Azure.Storage.common/12.9.0
Blob:https://www.nuget.org/packages/Azure.Storage.Blobs/12.10.0
佇列:https://www.nuget.org/packages/Azure.Storage.queues/12.8.0

GitHub 版本:
一般:https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Common_12.9.0/sdk/storage/Azure.Storage.Common
Blob:https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Blobs_12.10.0/sdk/storage/Azure.Storage.Blobs
佇列:https://github.com/Azure/azure-sdk-for-net/tree/Azure.Storage.Queues_12.8.0/sdk/storage/Azure.Storage.Queues
app.config 檔案
Java Common: 12.12.0
Blob:12.13.0
佇列:12.10.0
Maven 套件:
一般:https://mvnrepository.com/artifact/com.azure/azure-storage-common/12.12.0
Blob:https://mvnrepository.com/artifact/com.azure/azure-storage-blob/12.13.0
佇列:https://mvnrepository.com/artifact/com.azure/azure-storage-queue/12.10.0

GitHub 版本:
一般:https://github.com/Azure/azure-sdk-for-java/tree/azure-storage-common_12.12.0/sdk/storage/azure-storage-common
Blob:https://github.com/Azure/azure-sdk-for-java/tree/azure-storage-blob_12.13.0/sdk/storage/azure-storage-blob
佇列:https://github.com/Azure/azure-sdk-for-java/tree/azure-storage-queue_12.10.0/sdk/storage/azure-storage-queue
連接字串設定
Node.js 2.8.3 NPM 連結:
https://www.npmjs.com/package/azure-storage
(執行:npm install azure-storage@2.8.3)

GitHub 版本:
https://github.com/Azure/azure-storage-node/releases/tag/v2.8.3
服務執行個體宣告
C++ 7.2.0 GitHub 版本:
https://github.com/Azure/azure-storage-cpp/releases/tag/v7.2.0
連接字串設定
PHP 1.2.0 GitHub 版本:
一般: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-blob
佇列:
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-table

透過編輯器安裝 (若要深入了解,請參閱以下詳細資料)。
連接字串設定
Python Blob:12.3.1
佇列:12.1.6
GitHub 版本:
Blob:
https://github.com/Azure/azure-sdk-for-python/tree/azure-storage-blob_12.3.1/sdk/storage/azure-storage-blob
佇列:
https://github.com/Azure/azure-sdk-for-python/tree/azure-storage-queue_12.1.6/sdk/storage/azure-storage-queue
服務執行個體宣告
Ruby 1.0.1 RubyGems 套件:
一般:
https://rubygems.org/gems/azure-storage-common/versions/1.0.1
Blob:https://rubygems.org/gems/azure-storage-blob/versions/1.0.1
佇列:https://rubygems.org/gems/azure-storage-queue/versions/1.0.1
資料表:https://rubygems.org/gems/azure-storage-table/versions/1.0.1

GitHub 版本:
一般: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-blob
佇列: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-table
連接字串設定

透過編輯器安裝 PHP 用戶端 - 目前

若要透過編輯器安裝:(以 Blob 為例)。

  1. 在專案的根目錄中,使用下列程式碼建立一個名為 composer.json 的檔案:

    {
      "require": {
      "Microsoft/azure-storage-blob":"1.2.0"
      }
    }
    
  2. composer.phar 下載到專案根目錄中。

  3. 執行:php composer.phar install

指定 API 版本

若要使用新的 .NET 用戶端程式庫 (一般:v12.9.0/Blob:v12.10.0/佇列:v12.8.0) 和 Java 用戶端程式庫 (一般:v12.12.0/Blob:v12.13.0/佇列:v12.10.0),您必須在每個用戶端類別中明確指定 serviceVersion (包括 BlobServiceClientBlobContainerClientBlobClientQueueServiceClientQueueClient),因為 Azure Stack Hub 目前不支援用戶端類別中的預設版本。

範例

.NET
BlobClientOptions options = new BlobClientOptions(BlobClientOptions.ServiceVersion.V2019_07_07);
BlobServiceClient client = new BlobServiceClient("<connection_string>", options);
Java
BlobServiceVersion version = BlobServiceVersion.V2019_07_07; 
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
    .endpoint("<your_endpoint>")
    .sasToken("<your_SAS_token>")
    .serviceVersion(version)
    .buildClient();

2005 更新

用戶端程式庫 Azure Stack Hub 支援的版本 連結 端點規格
.NET 11.0.0 Nuget 套件:
一般:https://www.nuget.org/packages/Microsoft.Azure.Storage.Common/11.0.0
Blob:https://www.nuget.org/packages/Microsoft.Azure.Storage.Blob/11.0.0
佇列:
https://www.nuget.org/packages/Microsoft.Azure.Storage.Queue/11.0.0

GitHub 版本:
https://github.com/Azure/azure-storage-net/releases/tag/v11.0.0
app.config 檔案
Java 12.0.0-preview.3 Maven 套件:
https://mvnrepository.com/artifact/com.azure/azure-storage-blob/12.0.0-preview.3

GitHub 版本:
https://github.com/Azure/azure-sdk-for-java/tree/master/sdk/storage
連接字串設定
Node.js 2.8.3 NPM 連結:
https://www.npmjs.com/package/azure-storage
(執行:npm install azure-storage@2.8.3)

GitHub 版本:
https://github.com/Azure/azure-storage-node/releases/tag/v2.8.3
服務執行個體宣告
C++ 7.1.0 GitHub 版本:
https://github.com/Azure/azure-storage-cpp/releases/tag/v7.1.0
連接字串設定
PHP 1.2.0 GitHub 版本:
一般: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-blob
佇列:
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-table

透過編輯器安裝 (若要深入了解,請參閱以下詳細資料)。
連接字串設定
Python 2.1.0 GitHub 版本:
一般:
https://github.com/Azure/azure-storage-python/releases/tag/v2.1.0-common
Blob:
https://github.com/Azure/azure-storage-python/releases/tag/v2.1.0-blob
佇列:
https://github.com/Azure/azure-storage-python/releases/tag/v2.1.0-queue
服務執行個體宣告
Ruby 1.0.1 RubyGems 套件:
一般:
https://rubygems.org/gems/azure-storage-common/versions/1.0.1
Blob:https://rubygems.org/gems/azure-storage-blob/versions/1.0.1
佇列:https://rubygems.org/gems/azure-storage-queue/versions/1.0.1
資料表:https://rubygems.org/gems/azure-storage-table/versions/1.0.1

GitHub 版本:
一般: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-blob
佇列: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-table
連接字串設定

透過編輯器安裝 PHP 用戶端 - 目前

若要透過編輯器安裝:(以 Blob 為例)。

  1. 在專案的根目錄中,使用下列程式碼建立一個名為 composer.json 的檔案:

    {
      "require": {
      "Microsoft/azure-storage-blob":"1.2.0"
      }
    }
    
  2. composer.phar 下載到專案根目錄中。

  3. 執行:php composer.phar install

端點宣告

Azure Stack Hub 端點包含兩個部分:區域的名稱和 Azure Stack Hub 網域。 在 Azure Stack 開發套件中,預設端點是 local.azurestack.external。 如果不確定您的端點,請連絡您的雲端系統管理員。

範例

.NET

若是 Azure Stack Hub,在 app.config 檔案中會指定端點尾碼:

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

Java

若是 Azure Stack Hub,在連接字串設定中會指定端點尾碼:

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

Node.js

若是 Azure Stack Hub,在宣告執行個體中會指定端點尾碼:

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

C++

若是 Azure Stack Hub,在連接字串設定中會指定端點尾碼:

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

PHP

若是 Azure Stack Hub,在連接字串設定中會指定端點尾碼:

$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>'

Python

若是 Azure Stack Hub,在宣告執行個體中會指定端點尾碼:

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

Ruby

若是 Azure Stack Hub,在連接字串設定中會指定端點尾碼:

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

Blob 儲存體

下列 Azure Blob 儲存體教學課程適用於 Azure Stack Hub。 請注意先前範例一節中所述的 Azure Stack Hub 特定端點尾碼需求。

佇列儲存體

下列 Azure 佇列儲存體教學課程適用於 Azure Stack Hub。 請注意先前範例一節中所述的 Azure Stack Hub 特定端點尾碼需求。

資料表儲存體

下列 Azure 資料表儲存體教學課程適用於 Azure Stack Hub。 請注意先前範例一節中所述的 Azure Stack Hub 特定端點尾碼需求。

後續步驟