A set of samples for onboarding to and exploring the Azure Storage Resource Provider REST API.
- Copy .env.sample.txt and create a new file called
.env
.
-
Retrieve a bearer token for your Azure account and paste the value in the
BEARER_TOKEN
environment variable.Note: A bearer token can be retrieved through the REST API, the Azure CLI or through Azure PowerShell.
PowerShell
$tokenPoSh = ((New-Object Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient([Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile)).AcquireAccessToken((Gaz account get-access-tokenId)).AccessToken Write-Output $tokenPosh
Bash
tokenCLI=$(az account get-access-token --query "accessToken" -o tsv) echo $tokenCLI
-
Verify you can access your Azure subscription using the token by executing getsubscriptions.http.
-
In the response, find the target
subscriptionId
and past the value into theSUBSCRIPTION_ID
value in your.env
file. -
Populate the remaining values in your
.env
file, including:- LOCATION - Valid location name from listlocations.http
- RESOURCE_GROUP_NAME - Name for a new resource group that will be created with createresourcegroup.http or the name of an existing resource group
- STORAGE_ACCOUNT_NAME - Name for a new storage account created with createstorageaccount.http or the name of an existing storage account
- CONTAINER_NAME - Name for a new container created with createblobcontainer.http or the name of an existing container
Note: If you have an existing resource group and storage account you can use those values or you can use the samples in this repository to create the resources
-
Retrieve a bearer token for the resource
https://storage.azure.com
and paste the value in theBEARER_STORAGE
environment variable.Bash
tokenStorageCLI=$(az account get-access-token --resource=https://storage.azure.com/ --query "accessToken" -o tsv) echo $tokenStorageCLI