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
(PowerBuilder) Azure Create Storage AccountDemonstrates how to create an Azure storage account.
integer li_rc oleobject loo_Http oleobject loo_JsonToken integer li_Success oleobject loo_JsonRequestBody string ls_Url oleobject loo_Resp oleobject loo_Json string ls_SkuName string ls_SkuTier string ls_Kind string ls_Id string ls_Name string ls_V_type string ls_Location string ls_PropertiesNetworkAclsBypass string ls_PropertiesNetworkAclsDefaultAction integer li_PropertiesSupportsHttpsTrafficOnly integer li_PropertiesEncryptionServicesFileEnabled string ls_PropertiesEncryptionServicesFileLastEnabledTime integer li_PropertiesEncryptionServicesBlobEnabled string ls_PropertiesEncryptionServicesBlobLastEnabledTime string ls_PropertiesEncryptionKeySource string ls_PropertiesAccessTier string ls_PropertiesProvisioningState string ls_PropertiesCreationTime string ls_PropertiesPrimaryEndpointsDfs string ls_PropertiesPrimaryEndpointsWeb string ls_PropertiesPrimaryEndpointsBlob string ls_PropertiesPrimaryEndpointsQueue string ls_PropertiesPrimaryEndpointsTable string ls_PropertiesPrimaryEndpointsFile string ls_PropertiesPrimaryLocation string ls_PropertiesStatusOfPrimary string ls_PropertiesSecondaryLocation string ls_PropertiesStatusOfSecondary integer i integer li_Count_i // This example requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") if li_rc < 0 then destroy loo_Http MessageBox("Error","Connecting to COM object failed") return end if // Load an OAuth2 access token previously fetched by this example: Get Azure OAuth2 Access Token loo_JsonToken = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JsonToken.ConnectToNewObject("Chilkat.JsonObject") li_Success = loo_JsonToken.LoadFile("qa_data/tokens/azureToken.json") // Assuming success.. loo_Http.AuthToken = loo_JsonToken.StringOf("access_token") Write-Debug "AuthToken: " + loo_Http.AuthToken loo_Http.Accept = "application/json" // Create the following JSON: // { // "sku": { // "name": "Standard_GRS" // }, // "kind": "StorageV2", // "location": "eastus2", // } // Use this online tool to generate the code from sample JSON: // Generate Code to Create JSON loo_JsonRequestBody = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JsonRequestBody.ConnectToNewObject("Chilkat.JsonObject") loo_JsonRequestBody.UpdateString("sku.name","Standard_GRS") loo_JsonRequestBody.UpdateString("kind","StorageV2") loo_JsonRequestBody.UpdateString("location","eastus2") ls_Url = "https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}?api-version=2018-02-01" loo_Resp = loo_Http.PText("PUT",ls_Url,loo_JsonRequestBody.Emit(),"utf-8","application/json",0,0) if loo_Http.LastMethodSuccess <> 1 then Write-Debug loo_Http.LastErrorText destroy loo_Http destroy loo_JsonToken destroy loo_JsonRequestBody return end if Write-Debug "Response Status Code: " + string(loo_Resp.StatusCode) loo_Json = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_Json.ConnectToNewObject("Chilkat.JsonObject") loo_Json.Load(loo_Resp.BodyStr) loo_Json.EmitCompact = 0 Write-Debug loo_Json.Emit() if loo_Resp.StatusCode >= 300 then Write-Debug "Failed." destroy loo_Resp destroy loo_Http destroy loo_JsonToken destroy loo_JsonRequestBody destroy loo_Json return end if // Successful requests to create a new account return a 202 status code with an empty response body. The storage account is created asynchronously. // If the account already exists or is being provisioned, the request response has a 200 return code with the configuration of the existing storage account in the response body. if loo_Resp.StatusCode = 202 then Write-Debug "Azure-AsyncOperation: " + loo_Resp.GetHeaderField("Azure-AsyncOperation") end if if loo_Resp.StatusCode = 200 then // Parse a response like this: // { // "sku": { // "name": "Standard_GRS", // "tier": "Standard" // }, // "kind": "StorageV2", // "id": "/subscriptions/6c42643b-ebef-45f0-b917-b3583b84a57f/resourceGroups/gChilkat/providers/Microsoft.Storage/storageAccounts/chilkatsoftware", // "name": "chilkatsoftware", // "type": "Microsoft.Storage/storageAccounts", // "location": "eastus2", // "tags": {}, // "properties": { // "networkAcls": { // "bypass": "AzureServices", // "virtualNetworkRules": [ // ], // "ipRules": [ // ], // "defaultAction": "Allow" // }, // "supportsHttpsTrafficOnly": false, // "encryption": { // "services": { // "file": { // "enabled": true, // "lastEnabledTime": "2019-05-14T22:18:33.2246670Z" // }, // "blob": { // "enabled": true, // "lastEnabledTime": "2019-05-14T22:18:33.2246670Z" // } // }, // "keySource": "Microsoft.Storage" // }, // "accessTier": "Hot", // "provisioningState": "Succeeded", // // "creationTime": "2019-05-14T22:18:33.1309165Z", // "primaryEndpoints": { // "dfs": "https://chilkatsoftware.dfs.core.windows.net/", // "web": "https://chilkatsoftware.z20.web.core.windows.net/", // "blob": "https://chilkatsoftware.blob.core.windows.net/", // "queue": "https://chilkatsoftware.queue.core.windows.net/", // "table": "https://chilkatsoftware.table.core.windows.net/", // "file": "https://chilkatsoftware.file.core.windows.net/" // }, // "primaryLocation": "eastus2", // "statusOfPrimary": "available", // "secondaryLocation": "centralus", // "statusOfSecondary": "available" // } // } // Use this online tool to generate parsing code from sample JSON: // Generate Parsing Code from JSON ls_SkuName = loo_Json.StringOf("sku.name") ls_SkuTier = loo_Json.StringOf("sku.tier") ls_Kind = loo_Json.StringOf("kind") ls_Id = loo_Json.StringOf("id") ls_Name = loo_Json.StringOf("name") ls_V_type = loo_Json.StringOf("type") ls_Location = loo_Json.StringOf("location") ls_PropertiesNetworkAclsBypass = loo_Json.StringOf("properties.networkAcls.bypass") ls_PropertiesNetworkAclsDefaultAction = loo_Json.StringOf("properties.networkAcls.defaultAction") li_PropertiesSupportsHttpsTrafficOnly = loo_Json.BoolOf("properties.supportsHttpsTrafficOnly") li_PropertiesEncryptionServicesFileEnabled = loo_Json.BoolOf("properties.encryption.services.file.enabled") ls_PropertiesEncryptionServicesFileLastEnabledTime = loo_Json.StringOf("properties.encryption.services.file.lastEnabledTime") li_PropertiesEncryptionServicesBlobEnabled = loo_Json.BoolOf("properties.encryption.services.blob.enabled") ls_PropertiesEncryptionServicesBlobLastEnabledTime = loo_Json.StringOf("properties.encryption.services.blob.lastEnabledTime") ls_PropertiesEncryptionKeySource = loo_Json.StringOf("properties.encryption.keySource") ls_PropertiesAccessTier = loo_Json.StringOf("properties.accessTier") ls_PropertiesProvisioningState = loo_Json.StringOf("properties.provisioningState") ls_PropertiesCreationTime = loo_Json.StringOf("properties.creationTime") ls_PropertiesPrimaryEndpointsDfs = loo_Json.StringOf("properties.primaryEndpoints.dfs") ls_PropertiesPrimaryEndpointsWeb = loo_Json.StringOf("properties.primaryEndpoints.web") ls_PropertiesPrimaryEndpointsBlob = loo_Json.StringOf("properties.primaryEndpoints.blob") ls_PropertiesPrimaryEndpointsQueue = loo_Json.StringOf("properties.primaryEndpoints.queue") ls_PropertiesPrimaryEndpointsTable = loo_Json.StringOf("properties.primaryEndpoints.table") ls_PropertiesPrimaryEndpointsFile = loo_Json.StringOf("properties.primaryEndpoints.file") ls_PropertiesPrimaryLocation = loo_Json.StringOf("properties.primaryLocation") ls_PropertiesStatusOfPrimary = loo_Json.StringOf("properties.statusOfPrimary") ls_PropertiesSecondaryLocation = loo_Json.StringOf("properties.secondaryLocation") ls_PropertiesStatusOfSecondary = loo_Json.StringOf("properties.statusOfSecondary") end if Write-Debug "Success." destroy loo_Resp destroy loo_Http destroy loo_JsonToken destroy loo_JsonRequestBody destroy loo_Json |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.