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 更新和更新
注意
舊版 .NET 和 Java 用戶端連結庫發生高嚴重性弱點,因為與易受攻擊的 Jackson 套件版本相依性。 強烈建議使用最新支援的 .NET 和 Java 用戶端連結庫版本,以避免安全性問題。
透過編輯器安裝 PHP 用戶端 - 目前
若要透過 Composer 安裝:(以 Blob 為例)。
使用下列程式代碼,在專案的根目錄中建立名為 composer.json 的檔案:
{ "require": { "Microsoft/azure-storage-blob":"1.2.0" } }將 composer.phar 下載至專案根目錄。
執行:
php composer.phar install。
指定 API 版本
若要使用新的 .NET 用戶端連結庫(一般:v12.9.0 / Blob:v12.10.0 / 佇列:v12.8.0) 和 Java 用戶端連結庫(一般:v12.1 2.0 / Blob:v12.13.0 / 佇列:v12.10.0),您必須在每個用戶端類別中明確指定 serviceVersion(包括 BlobServiceClient、BlobContainerClient、 BlobContainerClient、 QueueClient,因為 Azure Stack Hub 目前不支援用戶端類別中的預設版本。
範例
。NET
BlobClientOptions options = new BlobClientOptions(BlobClientOptions.ServiceVersion.V2019_07_07);
BlobServiceClient client = new BlobServiceClient("<connection_string>", options);
爪哇島
BlobServiceVersion version = BlobServiceVersion.V2019_07_07;
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.endpoint("<your_endpoint>")
.sasToken("<your_SAS_token>")
.serviceVersion(version)
.buildClient();
2008 更新和更新
透過編輯器安裝 PHP 用戶端 - 目前
若要透過 Composer 安裝:(以 Blob 為例)。
使用下列程式代碼,在專案的根目錄中建立名為 composer.json 的檔案:
{ "require": { "Microsoft/azure-storage-blob":"1.2.0" } }將 composer.phar 下載至專案根目錄。
執行:
php composer.phar install。
指定 API 版本
若要使用新的 .NET 用戶端連結庫(一般:v12.9.0 / Blob:v12.10.0 / 佇列:v12.8.0) 和 Java 用戶端連結庫(一般:v12.1 2.0 / Blob:v12.13.0 / 佇列:v12.10.0),您必須在每個用戶端類別中明確指定 serviceVersion(包括 BlobServiceClient、BlobContainerClient、 BlobContainerClient、 QueueClient,因為 Azure Stack Hub 目前不支援用戶端類別中的預設版本。
範例
。NET
BlobClientOptions options = new BlobClientOptions(BlobClientOptions.ServiceVersion.V2019_07_07);
BlobServiceClient client = new BlobServiceClient("<connection_string>", options);
爪哇島
BlobServiceVersion version = BlobServiceVersion.V2019_07_07;
BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
.endpoint("<your_endpoint>")
.sasToken("<your_SAS_token>")
.serviceVersion(version)
.buildClient();
2005 更新
透過編輯器安裝 PHP 用戶端 - 目前
若要透過 Composer 安裝:(以 Blob 為例)。
使用下列程式代碼,在專案的根目錄中建立名為 composer.json 的檔案:
{ "require": { "Microsoft/azure-storage-blob":"1.2.0" } }將 composer.phar 下載至專案根目錄。
執行:
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;" />
爪哇島
針對 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')
紅寶石
針對 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 特定端點後綴需求。
- 使用 .NET 開始使用 Azure Blob 記憶體
- 如何使用 Java 中的 Blob 記憶體
- 如何使用來自Node.js的 Blob 記憶體
- 如何使用來自C++的 Blob 記憶體
- 如何使用 PHP 中的 Blob 記憶體
- 如何使用來自 Python 的 Azure Blob 記憶體
- 如何使用 Ruby 中的 Blob 記憶體
佇列儲存體
下列 Azure 佇列記憶體教學課程適用於 Azure Stack Hub。 請注意上一節所述的 Azure Stack Hub 特定端點後綴需求。
- 使用 .NET 開始使用 Azure 佇列記憶體
- 如何使用 Java 的佇列記憶體
- 如何使用 Node.js 的佇列儲存體
- 如何使用來自C++的佇列記憶體
- 如何使用 PHP 的佇列記憶體
- 如何使用 Python 的佇列記憶體
- 如何使用 Ruby 的佇列記憶體
表格儲存體
下列 Azure 表格記憶體教學課程適用於 Azure Stack Hub。 請注意上一節所述的 Azure Stack Hub 特定端點後綴需求。
- 使用 .NET 開始使用 Azure 資料表記憶體
- 如何使用 Java 的數據表記憶體
- 如何使用來自Node.js的 Azure 資料表記憶體
- 如何使用來自 C++ 的數據表記憶體
- 如何使用 PHP 的數據表記憶體
- 如何在 Python 中使用數據表記憶體
- 如何使用 Ruby 的數據表記憶體