Sample code for 30+ languages & platforms
PowerBuilder

Configure Azure Storage Shared Key Authentication

See more REST Examples

Demonstrates Rest.SetAuthAzureStorage, which associates an AuthAzureStorage provider so Chilkat automatically adds a Shared Key Authorization header. The provider supplies the account name, base64 account key, service, and scheme.

Background. Azure Storage Shared Key authorization signs each request with the account access key. The provider also manages the x-ms-version header required by the storage REST API.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Rest
integer li_BTls
integer li_BAutoReconnect
oleobject loo_AzAuth
string ls_ResponseText

li_Success = 0

loo_Rest = create oleobject
li_rc = loo_Rest.ConnectToNewObject("Chilkat.Rest")
if li_rc < 0 then
    destroy loo_Rest
    MessageBox("Error","Connecting to COM object failed")
    return
end if
li_BTls = 1
li_BAutoReconnect = 1
li_Success = loo_Rest.Connect("example.com",443,li_BTls,li_BAutoReconnect)
if li_Success = 0 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    return
end if

//  Configure Azure Storage Shared Key authentication.  Provide the account name, base64 account
//  access key, service, and (optionally) the x-ms-version.
loo_AzAuth = create oleobject
li_rc = loo_AzAuth.ConnectToNewObject("Chilkat.AuthAzureStorage")

loo_AzAuth.Account = "myStorageAccount"
//  Normally you would not hard-code secrets in source.  You should instead obtain them from an
//  interactive prompt, environment variable, or a secrets vault.
loo_AzAuth.AccessKey = "BASE64_ACCOUNT_ACCESS_KEY"
loo_AzAuth.Scheme = "SharedKey"
loo_AzAuth.Service = "Blob"
loo_AzAuth.XMsVersion = "2021-08-06"

//  Associate the provider so Chilkat automatically adds the Shared Key Authorization header.
li_Success = loo_Rest.SetAuthAzureStorage(loo_AzAuth)
if li_Success = 0 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_AzAuth
    return
end if

ls_ResponseText = loo_Rest.FullRequestNoBody("GET","/mycontainer?restype=container&comp=list")
if loo_Rest.LastMethodSuccess = 0 then
    Write-Debug loo_Rest.LastErrorText
    destroy loo_Rest
    destroy loo_AzAuth
    return
end if

Write-Debug ls_ResponseText


destroy loo_Rest
destroy loo_AzAuth