Go
Go
Azure List Storage Accounts
See more Azure Storage Accounts Examples
Demonstrates how to list Azure storage accounts.Chilkat Go Downloads
success := false
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http := chilkat.NewHttp()
// Load an OAuth2 access token previously fetched by this example: Get Azure OAuth2 Access Token
jsonToken := chilkat.NewJsonObject()
success = jsonToken.LoadFile("qa_data/tokens/azureToken.json")
// Assuming success..
http.SetAuthToken(jsonToken.StringOf("access_token"))
fmt.Println("AuthToken: ", http.AuthToken())
http.SetAccept("application/json")
url := "https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts?api-version=2018-11-01"
jsonResp := http.QuickGetStr(url)
if http.LastMethodSuccess() != true {
fmt.Println(http.LastErrorText())
http.DisposeHttp()
jsonToken.DisposeJsonObject()
return
}
fmt.Println("Response Status Code: ", http.LastStatus())
json := chilkat.NewJsonObject()
json.Load(*jsonResp)
json.SetEmitCompact(false)
fmt.Println(*json.Emit())
if http.LastStatus() != 200 {
fmt.Println("Failed.")
http.DisposeHttp()
jsonToken.DisposeJsonObject()
json.DisposeJsonObject()
return
}
// 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"
// }
// }
// ]
// }
//
var i int
var count_i int
var skuName *string = new(string)
var skuTier *string = new(string)
var kind *string = new(string)
var id *string = new(string)
var name *string = new(string)
var v_type *string = new(string)
var location *string = new(string)
var propertiesNetworkAclsBypass *string = new(string)
var propertiesNetworkAclsDefaultAction *string = new(string)
var propertiesSupportsHttpsTrafficOnly bool
var propertiesEncryptionServicesFileEnabled bool
var propertiesEncryptionServicesFileLastEnabledTime *string = new(string)
var propertiesEncryptionServicesBlobEnabled bool
var propertiesEncryptionServicesBlobLastEnabledTime *string = new(string)
var propertiesEncryptionKeySource *string = new(string)
var propertiesProvisioningState *string = new(string)
var propertiesCreationTime *string = new(string)
var propertiesPrimaryEndpointsBlob *string = new(string)
var propertiesPrimaryEndpointsQueue *string = new(string)
var propertiesPrimaryEndpointsTable *string = new(string)
var propertiesPrimaryEndpointsFile *string = new(string)
var propertiesPrimaryLocation *string = new(string)
var propertiesStatusOfPrimary *string = new(string)
i = 0
count_i = json.SizeOfArray("value")
for i < count_i {
json.SetI(i)
skuName = json.StringOf("value[i].sku.name")
skuTier = json.StringOf("value[i].sku.tier")
kind = json.StringOf("value[i].kind")
id = json.StringOf("value[i].id")
name = json.StringOf("value[i].name")
v_type = json.StringOf("value[i].type")
location = json.StringOf("value[i].location")
propertiesNetworkAclsBypass = json.StringOf("value[i].properties.networkAcls.bypass")
propertiesNetworkAclsDefaultAction = json.StringOf("value[i].properties.networkAcls.defaultAction")
propertiesSupportsHttpsTrafficOnly = json.BoolOf("value[i].properties.supportsHttpsTrafficOnly")
propertiesEncryptionServicesFileEnabled = json.BoolOf("value[i].properties.encryption.services.file.enabled")
propertiesEncryptionServicesFileLastEnabledTime = json.StringOf("value[i].properties.encryption.services.file.lastEnabledTime")
propertiesEncryptionServicesBlobEnabled = json.BoolOf("value[i].properties.encryption.services.blob.enabled")
propertiesEncryptionServicesBlobLastEnabledTime = json.StringOf("value[i].properties.encryption.services.blob.lastEnabledTime")
propertiesEncryptionKeySource = json.StringOf("value[i].properties.encryption.keySource")
propertiesProvisioningState = json.StringOf("value[i].properties.provisioningState")
propertiesCreationTime = json.StringOf("value[i].properties.creationTime")
propertiesPrimaryEndpointsBlob = json.StringOf("value[i].properties.primaryEndpoints.blob")
propertiesPrimaryEndpointsQueue = json.StringOf("value[i].properties.primaryEndpoints.queue")
propertiesPrimaryEndpointsTable = json.StringOf("value[i].properties.primaryEndpoints.table")
propertiesPrimaryEndpointsFile = json.StringOf("value[i].properties.primaryEndpoints.file")
propertiesPrimaryLocation = json.StringOf("value[i].properties.primaryLocation")
propertiesStatusOfPrimary = json.StringOf("value[i].properties.statusOfPrimary")
i = i + 1
}
http.DisposeHttp()
jsonToken.DisposeJsonObject()
json.DisposeJsonObject()