Azure Storage Accounts: Get Storage Account Properties and Endpoints
See more Azure Storage Accounts Examples
Reads an account by subscription, resource group, and account name. Displays string resource IDs, service endpoints, provisioning state, and selected security settings. Missing or null policy properties are reported as unspecified rather than treated as false. Consult the relevant service default when interpreting these fields. Account properties do not include access keys and do not establish that this identity can access stored data.
These calls manage Azure resources at management.azure.com. They do not upload or download stored data. Supply a current Microsoft Entra access token for Azure Resource Manager in private qa_data/tokens/azureToken.json, with a nonempty access_token string. For v2 client credentials, request https://management.azure.com/.default; obtain a new token when it expires. A storage account key, SAS, Microsoft Graph token, or Storage data-plane token is not an ARM token. Never print the token or commit its file.
Azure RBAC must grant the caller the required management actions at the appropriate scope. An app registration alone does not grant resource access. Management permissions and blob/file data permissions are distinct. These examples target public Azure; sovereign clouds require the corresponding authority, ARM endpoint, token audience, and continuation-host validation.
Chilkat Unicode C++ Downloads
#include <CkJsonObjectW.h>
#include <CkHttpW.h>
#include <CkHttpResponseW.h>
#include <CkUrlW.h>
void ChilkatSample(void)
{
bool success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global.UnlockBundle for sample code.
// This is Azure Resource Manager (the management plane), not a blob data request.
// Load an unexpired Microsoft Entra token whose audience is Azure Resource Manager.
// For the v2 token endpoint, request scope https://management.azure.com/.default.
// Keep the token file private and out of source control and public web directories.
CkJsonObjectW token;
token.put_Strict(true);
success = token.LoadFile(L"qa_data/tokens/azureToken.json");
if (success != true) {
wprintf(L"Could not load the private Azure Resource Manager token file.\n");
return;
}
if ((token.JsonTypeOf(L"access_token") != 1) || (token.StringOfEquals(L"access_token",L"",true) == true)) {
wprintf(L"A nonempty access_token string is required.\n");
return;
}
// Use your subscription ID as a string. The all-zero value is only a placeholder.
const wchar_t *subscriptionId = L"00000000-0000-0000-0000-000000000000";
CkHttpW http;
http.put_AuthToken(token.stringOf(L"access_token"));
http.put_Accept(L"application/json");
http.put_RequireSslCertVerify(true);
http.put_FollowRedirects(false);
http.put_ConnectTimeout(30);
http.put_ReadTimeout(60);
success = http.SetUrlVar(L"subscriptionId",subscriptionId);
if (success != true) {
wprintf(L"Could not encode subscription ID.\n");
return;
}
CkHttpResponseW response;
CkJsonObjectW result;
result.put_Strict(true);
CkUrlW parsed;
const wchar_t *resourceGroupName = L"my-resource-group";
success = http.SetUrlVar(L"resourceGroupName",resourceGroupName);
if (success != true) {
wprintf(L"Could not encode resource group.\n");
return;
}
const wchar_t *accountName = L"youruniquestorageaccount";
success = http.SetUrlVar(L"accountName",accountName);
if (success != true) {
wprintf(L"Could not encode account name.\n");
return;
}
const wchar_t *resourceUrl = L"https://management.azure.com/subscriptions/{$subscriptionId}/resourceGroups/{$resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{$accountName}?api-version=2026-09-01";
success = http.HttpNoBody(L"GET",resourceUrl,response);
if (response.get_StatusCode() == 0) {
wprintf(L"No HTTP response. Inspect LastErrorText privately; it may contain credentials.\n");
return;
}
if ((response.get_StatusCode() != 200)) {
wprintf(L"HTTP status: %d\n",response.get_StatusCode());
wprintf(L"Request ID: %s\n",response.getHeaderField(L"x-ms-request-id"));
wprintf(L"Retry-After: %s\n",response.getHeaderField(L"Retry-After"));
// Inspect the error body privately. Do not log tokens, headers, or full responses.
// For 401 check the token/audience; for 403 check Azure RBAC and policy.
// Honor Retry-After for 429 and use bounded backoff for transient failures.
return;
}
if (success != true) {
wprintf(L"The HTTP response could not be read completely.\n");
return;
}
success = result.Load(response.bodyStr());
if (success != true) {
wprintf(L"Expected a well-formed JSON response.\n");
return;
}
if (result.JsonTypeOf(L"id") != 1) {
wprintf(L"Missing or invalid id.\n");
return;
}
if (result.JsonTypeOf(L"name") != 1) {
wprintf(L"Missing or invalid name.\n");
return;
}
if (result.JsonTypeOf(L"id") == 1) {
wprintf(L"Resource ID: %s\n",result.stringOf(L"id"));
}
if (result.JsonTypeOf(L"name") == 1) {
wprintf(L"Name: %s\n",result.stringOf(L"name"));
}
if (result.JsonTypeOf(L"location") == 1) {
wprintf(L"Location: %s\n",result.stringOf(L"location"));
}
if (result.JsonTypeOf(L"kind") == 1) {
wprintf(L"Kind: %s\n",result.stringOf(L"kind"));
}
if (result.JsonTypeOf(L"sku.name") == 1) {
wprintf(L"SKU: %s\n",result.stringOf(L"sku.name"));
}
if (result.JsonTypeOf(L"properties.provisioningState") == 1) {
wprintf(L"Provisioning state: %s\n",result.stringOf(L"properties.provisioningState"));
}
if (result.JsonTypeOf(L"properties.primaryEndpoints.blob") == 1) {
wprintf(L"Blob endpoint: %s\n",result.stringOf(L"properties.primaryEndpoints.blob"));
}
if (result.JsonTypeOf(L"properties.primaryEndpoints.file") == 1) {
wprintf(L"File endpoint: %s\n",result.stringOf(L"properties.primaryEndpoints.file"));
}
if (result.JsonTypeOf(L"properties.minimumTlsVersion") == 1) {
wprintf(L"Minimum TLS: %s\n",result.stringOf(L"properties.minimumTlsVersion"));
}
if (result.JsonTypeOf(L"properties.publicNetworkAccess") == 1) {
wprintf(L"Public network access: %s\n",result.stringOf(L"properties.publicNetworkAccess"));
}
if (result.JsonTypeOf(L"properties.supportsHttpsTrafficOnly") == 5) {
wprintf(L"HTTPS only: %d\n",result.BoolOf(L"properties.supportsHttpsTrafficOnly"));
}
else {
wprintf(L"HTTPS only: not explicitly set; consult the service default.\n");
}
if (result.JsonTypeOf(L"properties.allowBlobPublicAccess") == 5) {
wprintf(L"Anonymous blob access allowed: %d\n",result.BoolOf(L"properties.allowBlobPublicAccess"));
}
else {
wprintf(L"Anonymous blob access allowed: not explicitly set; consult the service default.\n");
}
if (result.JsonTypeOf(L"properties.allowSharedKeyAccess") == 5) {
wprintf(L"Shared Key allowed: %d\n",result.BoolOf(L"properties.allowSharedKeyAccess"));
}
else {
wprintf(L"Shared Key allowed: not explicitly set; consult the service default.\n");
}
}