Sample code for 30+ languages & platforms
Xbase++

Azure List Storage Accounts

See more Azure Storage Accounts Examples

Demonstrates how to list Azure storage accounts.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oHttp
LOCAL oJsonToken
LOCAL cUrl
LOCAL cJsonResp
LOCAL oJson
LOCAL i
LOCAL nCount_i
LOCAL cSkuName
LOCAL cSkuTier
LOCAL cKind
LOCAL cId
LOCAL cName
LOCAL cV_type
LOCAL cLocation
LOCAL cPropertiesNetworkAclsBypass
LOCAL cPropertiesNetworkAclsDefaultAction
LOCAL nPropertiesSupportsHttpsTrafficOnly
LOCAL nPropertiesEncryptionServicesFileEnabled
LOCAL cPropertiesEncryptionServicesFileLastEnabledTime
LOCAL nPropertiesEncryptionServicesBlobEnabled
LOCAL cPropertiesEncryptionServicesBlobLastEnabledTime
LOCAL cPropertiesEncryptionKeySource
LOCAL cPropertiesProvisioningState
LOCAL cPropertiesCreationTime
LOCAL cPropertiesPrimaryEndpointsBlob
LOCAL cPropertiesPrimaryEndpointsQueue
LOCAL cPropertiesPrimaryEndpointsTable
LOCAL cPropertiesPrimaryEndpointsFile
LOCAL cPropertiesPrimaryLocation
LOCAL cPropertiesStatusOfPrimary

nSuccess := 0

//  This example requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

oHttp := CreateObject("Chilkat.Http")

//  Load an OAuth2 access token previously fetched by this example:  Get Azure OAuth2 Access Token
oJsonToken := CreateObject("Chilkat.JsonObject")
nSuccess := oJsonToken:LoadFile("qa_data/tokens/azureToken.json")
//  Assuming success..
oHttp:AuthToken := oJsonToken:StringOf("access_token")
? "AuthToken: " + oHttp:AuthToken

oHttp:Accept := "application/json"

cUrl := "https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts?api-version=2018-11-01"

cJsonResp := oHttp:QuickGetStr(cUrl)
IF (oHttp:LastMethodSuccess != 1)
    ? oHttp:LastErrorText
    oHttp:destroy()
    oJsonToken:destroy()
    RETURN
ENDIF

? "Response Status Code: " + Str(oHttp:LastStatus)

oJson := CreateObject("Chilkat.JsonObject")
oJson:Load(cJsonResp)
oJson:EmitCompact := 0
? oJson:Emit()

IF (oHttp:LastStatus != 200)
    ? "Failed."
    oHttp:destroy()
    oJsonToken:destroy()
    oJson:destroy()
    RETURN
ENDIF

//  Sample output...
//  (See the parsing code below..)
//  
//  Use this online tool to generate parsing code from sample JSON: 
//  Generate Parsing Code from JSON

//  {
//    "value": [
//      {
//        "sku": {
//          "name": "Standard_LRS",
//          "tier": "Standard"
//        },
//        "kind": "Storage",
//        "id": "/subscriptions/6c42643b-ebef-45e0-b917-b3583b84a57f/resourceGroups/gchilkat/providers/Microsoft.Storage/storageAccounts/chilkat",
//        "name": "chilkat",
//        "type": "Microsoft.Storage/storageAccounts",
//        "location": "eastus",
//        "tags": {},
//        "properties": {
//          "networkAcls": {
//            "bypass": "AzureServices",
//            "virtualNetworkRules": [
//            ],
//            "ipRules": [
//            ],
//            "defaultAction": "Allow"
//          },
//          "supportsHttpsTrafficOnly": true,
//          "encryption": {
//            "services": {
//              "file": {
//                "enabled": true,
//                "lastEnabledTime": "2017-12-28T11:02:10.6840887Z"
//              },
//              "blob": {
//                "enabled": true,
//                "lastEnabledTime": "2017-12-28T11:02:10.6840887Z"
//              }
//            },
//            "keySource": "Microsoft.Storage"
//          },
//          "provisioningState": "Succeeded",
//          "creationTime": "2016-04-18T22:57:36.5377065Z",
//          "primaryEndpoints": {
//            "blob": "https://chilkat.blob.core.windows.net/",
//            "queue": "https://chilkat.queue.core.windows.net/",
//            "table": "https://chilkat.table.core.windows.net/",
//            "file": "https://chilkat.file.core.windows.net/"
//          },
//          "primaryLocation": "eastus",
//          "statusOfPrimary": "available"
//        }
//      }
//    ]
//  }
//  

i := 0
nCount_i := oJson:SizeOfArray("value")
DO WHILE i < nCount_i
    oJson:I := i
    cSkuName := oJson:StringOf("value[i].sku.name")
    cSkuTier := oJson:StringOf("value[i].sku.tier")
    cKind := oJson:StringOf("value[i].kind")
    cId := oJson:StringOf("value[i].id")
    cName := oJson:StringOf("value[i].name")
    cV_type := oJson:StringOf("value[i].type")
    cLocation := oJson:StringOf("value[i].location")
    cPropertiesNetworkAclsBypass := oJson:StringOf("value[i].properties.networkAcls.bypass")
    cPropertiesNetworkAclsDefaultAction := oJson:StringOf("value[i].properties.networkAcls.defaultAction")
    nPropertiesSupportsHttpsTrafficOnly := oJson:BoolOf("value[i].properties.supportsHttpsTrafficOnly")
    nPropertiesEncryptionServicesFileEnabled := oJson:BoolOf("value[i].properties.encryption.services.file.enabled")
    cPropertiesEncryptionServicesFileLastEnabledTime := oJson:StringOf("value[i].properties.encryption.services.file.lastEnabledTime")
    nPropertiesEncryptionServicesBlobEnabled := oJson:BoolOf("value[i].properties.encryption.services.blob.enabled")
    cPropertiesEncryptionServicesBlobLastEnabledTime := oJson:StringOf("value[i].properties.encryption.services.blob.lastEnabledTime")
    cPropertiesEncryptionKeySource := oJson:StringOf("value[i].properties.encryption.keySource")
    cPropertiesProvisioningState := oJson:StringOf("value[i].properties.provisioningState")
    cPropertiesCreationTime := oJson:StringOf("value[i].properties.creationTime")
    cPropertiesPrimaryEndpointsBlob := oJson:StringOf("value[i].properties.primaryEndpoints.blob")
    cPropertiesPrimaryEndpointsQueue := oJson:StringOf("value[i].properties.primaryEndpoints.queue")
    cPropertiesPrimaryEndpointsTable := oJson:StringOf("value[i].properties.primaryEndpoints.table")
    cPropertiesPrimaryEndpointsFile := oJson:StringOf("value[i].properties.primaryEndpoints.file")
    cPropertiesPrimaryLocation := oJson:StringOf("value[i].properties.primaryLocation")
    cPropertiesStatusOfPrimary := oJson:StringOf("value[i].properties.statusOfPrimary")
    i := i + 1
ENDDO

oHttp:destroy()
oJsonToken:destroy()
oJson:destroy()