Get started with Azure Stack Hub storage development tools
Microsoft Azure Stack Hub provides a set of storage services that includes blob, table, and queue storage.
Use this article as a guide to get started using Azure Stack Hub storage development tools. You can find more detailed information and sample code in corresponding Azure storage tutorials.
Note
There are differences between Azure Stack Hub storage and Azure storage, including specific requirements for each platform. For example, there are specific client libraries and endpoint suffix requirements for Azure Stack Hub. For more information, see Azure Stack Hub storage: Differences and considerations.
For the storage client libraries, be aware of the version that is compatible with the REST API. You must also specify the Azure Stack Hub endpoint in your code.
Note
There is a high severity vulnerability in old version of .NET and Java client library, because of the dependencies on a vulnerable version of Jackson package. It is strongly suggested to use the latest supported version of .NET and Java client library to avoid security issue.
To install via Composer: (take the blob as an example).
Create a file named composer.json in the root of the project with following code:
JSON{ "require": { "Microsoft/azure-storage-blob":"1.2.0" } }
Download composer.phar to the project root.
Run:
php composer.phar install
.
To use the new .NET client library (Common: v12.9.0 / Blob: v12.10.0 / Queue: v12.8.0) and Java client library (Common: v12.12.0 / Blob: v12.13.0 / Queue: v12.10.0), you must explicitly specify the serviceVersion in each client class (including BlobServiceClient, BlobContainerClient, BlobClient, QueueServiceClient, and QueueClient), because the default version in the client class is not currently supported by Azure Stack Hub.
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();
To install via Composer: (take the blob as an example).
Create a file named composer.json in the root of the project with following code:
JSON{ "require": { "Microsoft/azure-storage-blob":"1.2.0" } }
Download composer.phar to the project root.
Run:
php composer.phar install
.
To use the new .NET client library (Common: v12.9.0 / Blob: v12.10.0 / Queue: v12.8.0) and Java client library (Common: v12.12.0 / Blob: v12.13.0 / Queue: v12.10.0), you must explicitly specify the serviceVersion in each client class (including BlobServiceClient, BlobContainerClient, BlobClient, QueueServiceClient, and QueueClient), because the default version in the client class is not currently supported by Azure Stack Hub.
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();
To install via Composer: (take the blob as an example).
Create a file named composer.json in the root of the project with following code:
JSON{ "require": { "Microsoft/azure-storage-blob":"1.2.0" } }
Download composer.phar to the project root.
Run:
php composer.phar install
.
An Azure Stack Hub endpoint includes two parts: the name of a region and the Azure Stack Hub domain. 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.
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;" />
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";
For Azure Stack Hub, the endpoint suffix is specified in the declaration instance:
var blobSvc = azure.createBlobService('myaccount', 'mykey',
'myaccount.blob.local.azurestack.external');
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"));
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>'
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')
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
The following Azure Blob storage tutorials are applicable to Azure Stack Hub. Note the specific endpoint suffix requirement for Azure Stack Hub described in the previous Examples section.
- Get started with Azure Blob storage using .NET
- How to use Blob storage from Java
- How to use Blob storage from Node.js
- How to use Blob storage from C++
- How to use Blob storage from PHP
- How to use Azure Blob storage from Python
- How to use Blob storage from Ruby
The following Azure Queue storage tutorials are applicable to Azure Stack Hub. Note the specific endpoint suffix requirement for Azure Stack Hub described in the previous Examples section.
- Get started with Azure Queue storage using .NET
- How to use Queue storage from Java
- How to use Queue storage from Node.js
- How to use Queue storage from C++
- How to use Queue storage from PHP
- How to use Queue storage from Python
- How to use Queue storage from Ruby
The following Azure Table storage tutorials are applicable to Azure Stack Hub. Note the specific endpoint suffix requirement for Azure Stack Hub described in the previous Examples section.