Azure Storage Accounts: List Storage Accounts in a Resource Group
See more Azure Storage Accounts Examples
Lists accounts in one existing resource group. Requires account read permission at the appropriate scope. Follows opaque continuation URLs without rewriting their query strings and handles empty pages, repeated links, and incomplete results. Resource IDs remain strings; no account keys are requested.
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 Xojo Plugin Downloads
Dim success As Boolean
success = False
Dim stringCompare As New Chilkat.StringBuilder
// 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.
Dim token As New Chilkat.JsonObject
token.Strict = True
success = token.LoadFile("qa_data/tokens/azureToken.json")
If (success <> True) Then
System.DebugLog("Could not load the private Azure Resource Manager token file.")
Return
End If
If ((token.JsonTypeOf("access_token") <> 1) Or (token.StringOfEquals("access_token","",True) = True)) Then
System.DebugLog("A nonempty access_token string is required.")
Return
End If
// Use your subscription ID as a string. The all-zero value is only a placeholder.
Dim subscriptionId As String
subscriptionId = "00000000-0000-0000-0000-000000000000"
Dim http As New Chilkat.Http
http.AuthToken = token.StringOf("access_token")
http.Accept = "application/json"
http.RequireSslCertVerify = True
http.FollowRedirects = False
http.ConnectTimeout = 30
http.ReadTimeout = 60
success = http.SetUrlVar("subscriptionId",subscriptionId)
If (success <> True) Then
System.DebugLog("Could not encode subscription ID.")
Return
End If
Dim response As New Chilkat.HttpResponse
Dim result As New Chilkat.JsonObject
result.Strict = True
Dim parsed As New Chilkat.Url
Dim resourceGroupName As String
resourceGroupName = "my-resource-group"
success = http.SetUrlVar("resourceGroupName",resourceGroupName)
If (success <> True) Then
System.DebugLog("Could not encode resource group.")
Return
End If
// Http substitutes and URL-encodes {$subscriptionId} in this first request.
Dim requestUrl As String
requestUrl = "https://management.azure.com/subscriptions/{$subscriptionId}/resourceGroups/{$resourceGroupName}/providers/Microsoft.Storage/storageAccounts?api-version=2026-09-01"
Dim seen As New Chilkat.Hashtable
Dim accounts As New Chilkat.JsonArray
Dim account As New Chilkat.JsonObject
Dim morePages As Boolean
morePages = True
Dim page As Int32
page = 0
Dim total As Int32
total = 0
While (morePages = True)
// A limit and a repeated-link check protect against an endless continuation loop.
If (page >= 1000) Then
System.DebugLog("Page limit reached. Listing is incomplete; resume from: " + requestUrl)
Return
End If
If (seen.Contains(requestUrl) = True) Then
System.DebugLog("Repeated continuation URL; listing is incomplete.")
Return
End If
success = seen.AddStr(requestUrl,"seen")
If (success <> True) Then
System.DebugLog("Could not record the continuation URL.")
Return
End If
success = http.HttpNoBody("GET",requestUrl,response)
If (response.StatusCode = 0) Then
System.DebugLog("No HTTP response. Inspect LastErrorText privately; it may contain credentials.")
Return
End If
If ((response.StatusCode <> 200)) Then
System.DebugLog("HTTP status: " + Str(response.StatusCode))
System.DebugLog("Request ID: " + response.GetHeaderField("x-ms-request-id"))
System.DebugLog("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
End If
If (success <> True) Then
System.DebugLog("The HTTP response could not be read completely.")
Return
End If
success = result.Load(response.BodyStr)
If (success <> True) Then
System.DebugLog("Expected a well-formed JSON response.")
Return
End If
If (result.JsonTypeOf("value") <> 4) Then
System.DebugLog("Expected a value array of storage accounts.")
Return
End If
success = result.ArrayOf2("value",accounts)
If (success <> True) Then
System.DebugLog("Could not read the storage account array.")
Return
End If
Dim i As Int32
i = 0
While (i < accounts.Size)
success = accounts.ObjectAt2(i,account)
If (success <> True) Then
System.DebugLog("Invalid storage account entry.")
Return
End If
If ((account.JsonTypeOf("id") <> 1) Or (account.JsonTypeOf("name") <> 1)) Then
System.DebugLog("Expected a storage account ID and name.")
Return
End If
// ARM resource IDs are strings, not numbers. Save id for later management calls.
System.DebugLog("Name: " + account.StringOf("name"))
System.DebugLog("Resource ID: " + account.StringOf("id"))
System.DebugLog("Location: " + account.StringOf("location"))
System.DebugLog("Kind: " + account.StringOf("kind"))
System.DebugLog("SKU: " + account.StringOf("sku.name"))
System.DebugLog("Provisioning state: " + account.StringOf("properties.provisioningState"))
// Endpoint availability depends on account kind and provisioning state.
If (account.JsonTypeOf("properties.primaryEndpoints.blob") = 1) Then
System.DebugLog("Blob endpoint: " + account.StringOf("properties.primaryEndpoints.blob"))
End If
total = total + 1
i = i + 1
Wend
page = page + 1
morePages = False
If (result.HasMember("nextLink") = True) Then
If ((result.IsNullOf("nextLink") <> True) And (result.JsonTypeOf("nextLink") <> 1)) Then
System.DebugLog("Invalid nextLink; listing is incomplete.")
Return
End If
If ((result.JsonTypeOf("nextLink") = 1) And (result.StringOfEquals("nextLink","",True) <> True)) Then
requestUrl = result.StringOf("nextLink")
success = parsed.ParseUrl(requestUrl)
If (success <> True) Then
System.DebugLog("Missing or invalid continuation URL.")
Return
End If
success = stringCompare.SetString(parsed.Scheme)
Dim stringMatch1 As Boolean
stringMatch1 = stringCompare.ContentsEqual("https",True)
success = stringCompare.SetString(parsed.Host)
Dim stringMatch2 As Boolean
stringMatch2 = stringCompare.ContentsEqual("management.azure.com",True)
success = stringCompare.SetString(parsed.Login)
Dim stringMatch3 As Boolean
stringMatch3 = stringCompare.ContentsEqual("",True)
success = stringCompare.SetString(parsed.Password)
Dim stringMatch4 As Boolean
stringMatch4 = stringCompare.ContentsEqual("",True)
success = stringCompare.SetString(parsed.Frag)
Dim stringMatch5 As Boolean
stringMatch5 = stringCompare.ContentsEqual("",True)
If ((stringMatch1 <> True) Or (stringMatch2 <> True) Or (parsed.Port <> 443) Or (stringMatch3 <> True) Or (stringMatch4 <> True) Or (stringMatch5 <> True)) Then
System.DebugLog("Unexpected continuation URL; refusing to send the access token.")
Return
End If
// The server owns nextLink. Keep its query intact; do not add api-version.
// Continue even if the current page contained no accounts.
morePages = True
End If
End If
Wend
System.DebugLog("Listing complete. Storage accounts: " + Str(total))