Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

SQL Server Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(SQL Server) Azure Create Storage Account

Demonstrates how to create an Azure storage account.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

// Important: See this note about string length limitations for strings returned by sp_OAMethod calls.
//
CREATE PROCEDURE ChilkatSample
AS
BEGIN
    DECLARE @hr int
    DECLARE @iTmp0 int
    DECLARE @sTmp0 nvarchar(4000)
    -- This example requires the Chilkat API to have been previously unlocked.
    -- See Global Unlock Sample for sample code.

    DECLARE @http int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.Http', @http OUT
    IF @hr <> 0
    BEGIN
        PRINT 'Failed to create ActiveX component'
        RETURN
    END

    -- Load an OAuth2 access token previously fetched by this example:  Get Azure OAuth2 Access Token
    DECLARE @jsonToken int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jsonToken OUT

    DECLARE @success int
    EXEC sp_OAMethod @jsonToken, 'LoadFile', @success OUT, 'qa_data/tokens/azureToken.json'
    -- Assuming success..
    EXEC sp_OAMethod @jsonToken, 'StringOf', @sTmp0 OUT, 'access_token'
    EXEC sp_OASetProperty @http, 'AuthToken', @sTmp0

    EXEC sp_OAGetProperty @http, 'AuthToken', @sTmp0 OUT
    PRINT 'AuthToken: ' + @sTmp0

    EXEC sp_OASetProperty @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

    DECLARE @jsonRequestBody int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @jsonRequestBody OUT

    EXEC sp_OAMethod @jsonRequestBody, 'UpdateString', @success OUT, 'sku.name', 'Standard_GRS'
    EXEC sp_OAMethod @jsonRequestBody, 'UpdateString', @success OUT, 'kind', 'StorageV2'
    EXEC sp_OAMethod @jsonRequestBody, 'UpdateString', @success OUT, 'location', 'eastus2'

    DECLARE @url nvarchar(4000)
    SELECT @url = 'https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Storage/storageAccounts/{accountName}?api-version=2018-02-01'

    DECLARE @resp int
    EXEC sp_OAMethod @jsonRequestBody, 'Emit', @sTmp0 OUT
    EXEC sp_OAMethod @http, 'PText', @resp OUT, 'PUT', @url, @sTmp0, 'utf-8', 'application/json', 0, 0
    EXEC sp_OAGetProperty @http, 'LastMethodSuccess', @iTmp0 OUT
    IF @iTmp0 <> 1
      BEGIN
        EXEC sp_OAGetProperty @http, 'LastErrorText', @sTmp0 OUT
        PRINT @sTmp0
        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @jsonToken
        EXEC @hr = sp_OADestroy @jsonRequestBody
        RETURN
      END


    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    PRINT 'Response Status Code: ' + @iTmp0

    DECLARE @json int
    EXEC @hr = sp_OACreate 'Chilkat_9_5_0.JsonObject', @json OUT

    EXEC sp_OAGetProperty @resp, 'BodyStr', @sTmp0 OUT
    EXEC sp_OAMethod @json, 'Load', @success OUT, @sTmp0
    EXEC sp_OASetProperty @json, 'EmitCompact', 0
    EXEC sp_OAMethod @json, 'Emit', @sTmp0 OUT
    PRINT @sTmp0

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    IF @iTmp0 >= 300
      BEGIN

        PRINT 'Failed.'
        EXEC @hr = sp_OADestroy @resp

        EXEC @hr = sp_OADestroy @http
        EXEC @hr = sp_OADestroy @jsonToken
        EXEC @hr = sp_OADestroy @jsonRequestBody
        EXEC @hr = sp_OADestroy @json
        RETURN
      END

    -- 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.
    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    IF @iTmp0 = 202
      BEGIN

        EXEC sp_OAMethod @resp, 'GetHeaderField', @sTmp0 OUT, 'Azure-AsyncOperation'
        PRINT 'Azure-AsyncOperation: ' + @sTmp0
      END

    EXEC sp_OAGetProperty @resp, 'StatusCode', @iTmp0 OUT
    IF @iTmp0 = 200
      BEGIN

        -- 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

        DECLARE @skuName nvarchar(4000)

        DECLARE @skuTier nvarchar(4000)

        DECLARE @kind nvarchar(4000)

        DECLARE @id nvarchar(4000)

        DECLARE @name nvarchar(4000)

        DECLARE @v_type nvarchar(4000)

        DECLARE @location nvarchar(4000)

        DECLARE @propertiesNetworkAclsBypass nvarchar(4000)

        DECLARE @propertiesNetworkAclsDefaultAction nvarchar(4000)

        DECLARE @propertiesSupportsHttpsTrafficOnly int

        DECLARE @propertiesEncryptionServicesFileEnabled int

        DECLARE @propertiesEncryptionServicesFileLastEnabledTime nvarchar(4000)

        DECLARE @propertiesEncryptionServicesBlobEnabled int

        DECLARE @propertiesEncryptionServicesBlobLastEnabledTime nvarchar(4000)

        DECLARE @propertiesEncryptionKeySource nvarchar(4000)

        DECLARE @propertiesAccessTier nvarchar(4000)

        DECLARE @propertiesProvisioningState nvarchar(4000)

        DECLARE @propertiesCreationTime nvarchar(4000)

        DECLARE @propertiesPrimaryEndpointsDfs nvarchar(4000)

        DECLARE @propertiesPrimaryEndpointsWeb nvarchar(4000)

        DECLARE @propertiesPrimaryEndpointsBlob nvarchar(4000)

        DECLARE @propertiesPrimaryEndpointsQueue nvarchar(4000)

        DECLARE @propertiesPrimaryEndpointsTable nvarchar(4000)

        DECLARE @propertiesPrimaryEndpointsFile nvarchar(4000)

        DECLARE @propertiesPrimaryLocation nvarchar(4000)

        DECLARE @propertiesStatusOfPrimary nvarchar(4000)

        DECLARE @propertiesSecondaryLocation nvarchar(4000)

        DECLARE @propertiesStatusOfSecondary nvarchar(4000)

        DECLARE @i int

        DECLARE @count_i int

        EXEC sp_OAMethod @json, 'StringOf', @skuName OUT, 'sku.name'
        EXEC sp_OAMethod @json, 'StringOf', @skuTier OUT, 'sku.tier'
        EXEC sp_OAMethod @json, 'StringOf', @kind OUT, 'kind'
        EXEC sp_OAMethod @json, 'StringOf', @id OUT, 'id'
        EXEC sp_OAMethod @json, 'StringOf', @name OUT, 'name'
        EXEC sp_OAMethod @json, 'StringOf', @v_type OUT, 'type'
        EXEC sp_OAMethod @json, 'StringOf', @location OUT, 'location'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesNetworkAclsBypass OUT, 'properties.networkAcls.bypass'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesNetworkAclsDefaultAction OUT, 'properties.networkAcls.defaultAction'
        EXEC sp_OAMethod @json, 'BoolOf', @propertiesSupportsHttpsTrafficOnly OUT, 'properties.supportsHttpsTrafficOnly'
        EXEC sp_OAMethod @json, 'BoolOf', @propertiesEncryptionServicesFileEnabled OUT, 'properties.encryption.services.file.enabled'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesEncryptionServicesFileLastEnabledTime OUT, 'properties.encryption.services.file.lastEnabledTime'
        EXEC sp_OAMethod @json, 'BoolOf', @propertiesEncryptionServicesBlobEnabled OUT, 'properties.encryption.services.blob.enabled'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesEncryptionServicesBlobLastEnabledTime OUT, 'properties.encryption.services.blob.lastEnabledTime'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesEncryptionKeySource OUT, 'properties.encryption.keySource'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesAccessTier OUT, 'properties.accessTier'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesProvisioningState OUT, 'properties.provisioningState'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesCreationTime OUT, 'properties.creationTime'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesPrimaryEndpointsDfs OUT, 'properties.primaryEndpoints.dfs'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesPrimaryEndpointsWeb OUT, 'properties.primaryEndpoints.web'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesPrimaryEndpointsBlob OUT, 'properties.primaryEndpoints.blob'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesPrimaryEndpointsQueue OUT, 'properties.primaryEndpoints.queue'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesPrimaryEndpointsTable OUT, 'properties.primaryEndpoints.table'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesPrimaryEndpointsFile OUT, 'properties.primaryEndpoints.file'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesPrimaryLocation OUT, 'properties.primaryLocation'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesStatusOfPrimary OUT, 'properties.statusOfPrimary'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesSecondaryLocation OUT, 'properties.secondaryLocation'
        EXEC sp_OAMethod @json, 'StringOf', @propertiesStatusOfSecondary OUT, 'properties.statusOfSecondary'
      END


    PRINT 'Success.'

    EXEC @hr = sp_OADestroy @resp


    EXEC @hr = sp_OADestroy @http
    EXEC @hr = sp_OADestroy @jsonToken
    EXEC @hr = sp_OADestroy @jsonRequestBody
    EXEC @hr = sp_OADestroy @json


END
GO

 

© 2000-2024 Chilkat Software, Inc. All Rights Reserved.