Delphi DLL
Delphi DLL
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 Delphi DLL Downloads
var
success: Boolean;
rest: HCkRest;
bTls: Boolean;
bAutoReconnect: Boolean;
azAuth: HCkAuthAzureStorage;
responseText: PWideChar;
begin
success := False;
rest := CkRest_Create();
bTls := True;
bAutoReconnect := True;
success := CkRest_Connect(rest,'example.com',443,bTls,bAutoReconnect);
if (success = False) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
// Configure Azure Storage Shared Key authentication. Provide the account name, base64 account
// access key, service, and (optionally) the x-ms-version.
azAuth := CkAuthAzureStorage_Create();
CkAuthAzureStorage_putAccount(azAuth,'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.
CkAuthAzureStorage_putAccessKey(azAuth,'BASE64_ACCOUNT_ACCESS_KEY');
CkAuthAzureStorage_putScheme(azAuth,'SharedKey');
CkAuthAzureStorage_putService(azAuth,'Blob');
CkAuthAzureStorage_putXMsVersion(azAuth,'2021-08-06');
// Associate the provider so Chilkat automatically adds the Shared Key Authorization header.
success := CkRest_SetAuthAzureStorage(rest,azAuth);
if (success = False) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
responseText := CkRest__fullRequestNoBody(rest,'GET','/mycontainer?restype=container&comp=list');
if (CkRest_getLastMethodSuccess(rest) = False) then
begin
Memo1.Lines.Add(CkRest__lastErrorText(rest));
Exit;
end;
Memo1.Lines.Add(responseText);
CkRest_Dispose(rest);
CkAuthAzureStorage_Dispose(azAuth);