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.
Azure client libraries
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.
2301 update and newer
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.
Install PHP client via Composer - current
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:
{ "require": { "Microsoft/azure-storage-blob":"1.2.0" } }
Download composer.phar to the project root.
Run:
php composer.phar install
.
Specify API version
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.
Examples
.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 update and newer
Install PHP client via Composer - current
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:
{ "require": { "Microsoft/azure-storage-blob":"1.2.0" } }
Download composer.phar to the project root.
Run:
php composer.phar install
.
Specify API version
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.
Examples
.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 update
Install PHP client via Composer - current
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:
{ "require": { "Microsoft/azure-storage-blob":"1.2.0" } }
Download composer.phar to the project root.
Run:
php composer.phar install
.
Endpoint declaration
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.
Examples
.NET
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;" />
Java
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.js
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++
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"));
PHP
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>'
Python
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')
Ruby
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 storage
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
Queue storage
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
Table storage
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.
- Get started with Azure Table storage using .NET
- How to use Table storage from Java
- How to use Azure Table storage from Node.js
- How to use Table storage from C++
- How to use Table storage from PHP
- How to use Table storage in Python
- How to use Table storage from Ruby