Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Node.js) Azure List Storage AccountsDemonstrates how to list Azure storage accounts.
var os = require('os'); if (os.platform() == 'win32') { if (os.arch() == 'ia32') { var chilkat = require('@chilkat/ck-node21-win-ia32'); } else { var chilkat = require('@chilkat/ck-node21-win64'); } } else if (os.platform() == 'linux') { if (os.arch() == 'arm') { var chilkat = require('@chilkat/ck-node21-arm'); } else if (os.arch() == 'x86') { var chilkat = require('@chilkat/ck-node21-linux32'); } else { var chilkat = require('@chilkat/ck-node21-linux64'); } } else if (os.platform() == 'darwin') { if (os.arch() == 'arm64') { var chilkat = require('@chilkat/ck-node21-mac-m1'); } else { var chilkat = require('@chilkat/ck-node21-macosx'); } } function chilkatExample() { // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. var http = new chilkat.Http(); // Load an OAuth2 access token previously fetched by this example: Get Azure OAuth2 Access Token var jsonToken = new chilkat.JsonObject(); var success = jsonToken.LoadFile("qa_data/tokens/azureToken.json"); // Assuming success.. http.AuthToken = jsonToken.StringOf("access_token"); console.log("AuthToken: " + http.AuthToken); http.Accept = "application/json"; var url = "https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Storage/storageAccounts?api-version=2018-11-01"; var jsonResp = http.QuickGetStr(url); if (http.LastMethodSuccess !== true) { console.log(http.LastErrorText); return; } console.log("Response Status Code: " + http.LastStatus); var json = new chilkat.JsonObject(); json.Load(jsonResp); json.EmitCompact = false; console.log(json.Emit()); if (http.LastStatus !== 200) { console.log("Failed."); 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; var count_i; var skuName; var skuTier; var kind; var id; var name; var v_type; var location; var propertiesNetworkAclsBypass; var propertiesNetworkAclsDefaultAction; var propertiesSupportsHttpsTrafficOnly; var propertiesEncryptionServicesFileEnabled; var propertiesEncryptionServicesFileLastEnabledTime; var propertiesEncryptionServicesBlobEnabled; var propertiesEncryptionServicesBlobLastEnabledTime; var propertiesEncryptionKeySource; var propertiesProvisioningState; var propertiesCreationTime; var propertiesPrimaryEndpointsBlob; var propertiesPrimaryEndpointsQueue; var propertiesPrimaryEndpointsTable; var propertiesPrimaryEndpointsFile; var propertiesPrimaryLocation; var propertiesStatusOfPrimary; i = 0; count_i = json.SizeOfArray("value"); while (i < count_i) { json.I = 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; } } chilkatExample(); |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.