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 Objective-C Downloads
#import <CkoJsonObject.h>
#import <NSString.h>
#import <CkoHttp.h>
#import <CkoHttpResponse.h>
#import <CkoUrl.h>
BOOL success = NO;
// 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.
CkoJsonObject *token = [[CkoJsonObject alloc] init];
token.Strict = YES;
success = [token LoadFile: @"qa_data/tokens/azureToken.json"];
if (success != YES) {
NSLog(@"%@",@"Could not load the private Azure Resource Manager token file.");
return;
}
if (([[token JsonTypeOf: @"access_token"] intValue] != 1) || ([token StringOfEquals: @"access_token" value: @"" caseSensitive: YES] == YES)) {
NSLog(@"%@",@"A nonempty access_token string is required.");
return;
}
// Use your subscription ID as a string. The all-zero value is only a placeholder.
NSString *subscriptionId = @"00000000-0000-0000-0000-000000000000";
CkoHttp *http = [[CkoHttp alloc] init];
http.AuthToken = [token StringOf: @"access_token"];
http.Accept = @"application/json";
http.RequireSslCertVerify = YES;
http.FollowRedirects = NO;
http.ConnectTimeout = [NSNumber numberWithInt:30];
http.ReadTimeout = [NSNumber numberWithInt:60];
success = [http SetUrlVar: @"subscriptionId" value: subscriptionId];
if (success != YES) {
NSLog(@"%@",@"Could not encode subscription ID.");
return;
}
CkoHttpResponse *response = [[CkoHttpResponse alloc] init];
CkoJsonObject *result = [[CkoJsonObject alloc] init];
result.Strict = YES;
CkoUrl *parsed = [[CkoUrl alloc] init];
NSString *resourceGroupName = @"my-resource-group";
success = [http SetUrlVar: @"resourceGroupName" value: resourceGroupName];
if (success != YES) {
NSLog(@"%@",@"Could not encode resource group.");
return;
}
NSString *accountName = @"youruniquestorageaccount";
success = [http SetUrlVar: @"accountName" value: accountName];
if (success != YES) {
NSLog(@"%@",@"Could not encode account name.");
return;
}
NSString *resourceUrl = @"https://management.azure.com/subscriptions/{$subscriptionId}/resourceGroups/{$resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{$accountName}?api-version=2026-09-01";
success = [http HttpNoBody: @"GET" url: resourceUrl response: response];
if ([response.StatusCode intValue] == 0) {
NSLog(@"%@",@"No HTTP response. Inspect LastErrorText privately; it may contain credentials.");
return;
}
if (([response.StatusCode intValue] != 200)) {
NSLog(@"%@%d",@"HTTP status: ",[response.StatusCode intValue]);
NSLog(@"%@%@",@"Request ID: ",[response GetHeaderField: @"x-ms-request-id"]);
NSLog(@"%@%@",@"Retry-After: ",[response GetHeaderField: @"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 != YES) {
NSLog(@"%@",@"The HTTP response could not be read completely.");
return;
}
success = [result Load: response.BodyStr];
if (success != YES) {
NSLog(@"%@",@"Expected a well-formed JSON response.");
return;
}
if ([[result JsonTypeOf: @"id"] intValue] != 1) {
NSLog(@"%@",@"Missing or invalid id.");
return;
}
if ([[result JsonTypeOf: @"name"] intValue] != 1) {
NSLog(@"%@",@"Missing or invalid name.");
return;
}
if ([[result JsonTypeOf: @"id"] intValue] == 1) {
NSLog(@"%@%@",@"Resource ID: ",[result StringOf: @"id"]);
}
if ([[result JsonTypeOf: @"name"] intValue] == 1) {
NSLog(@"%@%@",@"Name: ",[result StringOf: @"name"]);
}
if ([[result JsonTypeOf: @"location"] intValue] == 1) {
NSLog(@"%@%@",@"Location: ",[result StringOf: @"location"]);
}
if ([[result JsonTypeOf: @"kind"] intValue] == 1) {
NSLog(@"%@%@",@"Kind: ",[result StringOf: @"kind"]);
}
if ([[result JsonTypeOf: @"sku.name"] intValue] == 1) {
NSLog(@"%@%@",@"SKU: ",[result StringOf: @"sku.name"]);
}
if ([[result JsonTypeOf: @"properties.provisioningState"] intValue] == 1) {
NSLog(@"%@%@",@"Provisioning state: ",[result StringOf: @"properties.provisioningState"]);
}
if ([[result JsonTypeOf: @"properties.primaryEndpoints.blob"] intValue] == 1) {
NSLog(@"%@%@",@"Blob endpoint: ",[result StringOf: @"properties.primaryEndpoints.blob"]);
}
if ([[result JsonTypeOf: @"properties.primaryEndpoints.file"] intValue] == 1) {
NSLog(@"%@%@",@"File endpoint: ",[result StringOf: @"properties.primaryEndpoints.file"]);
}
if ([[result JsonTypeOf: @"properties.minimumTlsVersion"] intValue] == 1) {
NSLog(@"%@%@",@"Minimum TLS: ",[result StringOf: @"properties.minimumTlsVersion"]);
}
if ([[result JsonTypeOf: @"properties.publicNetworkAccess"] intValue] == 1) {
NSLog(@"%@%@",@"Public network access: ",[result StringOf: @"properties.publicNetworkAccess"]);
}
if ([[result JsonTypeOf: @"properties.supportsHttpsTrafficOnly"] intValue] == 5) {
NSLog(@"%@%d",@"HTTPS only: ",[result BoolOf: @"properties.supportsHttpsTrafficOnly"]);
}
else {
NSLog(@"%@",@"HTTPS only: not explicitly set; consult the service default.");
}
if ([[result JsonTypeOf: @"properties.allowBlobPublicAccess"] intValue] == 5) {
NSLog(@"%@%d",@"Anonymous blob access allowed: ",[result BoolOf: @"properties.allowBlobPublicAccess"]);
}
else {
NSLog(@"%@",@"Anonymous blob access allowed: not explicitly set; consult the service default.");
}
if ([[result JsonTypeOf: @"properties.allowSharedKeyAccess"] intValue] == 5) {
NSLog(@"%@%d",@"Shared Key allowed: ",[result BoolOf: @"properties.allowSharedKeyAccess"]);
}
else {
NSLog(@"%@",@"Shared Key allowed: not explicitly set; consult the service default.");
}