Integrations with Azure cloud services.

Azure Storage Integration

First of all we have to create AzureAccount resource with id = account name and key = secret key of your account. Your account name and keys you can find under "Access keys" section in azure.

POST /AzureAccount
id: aidbox
key: <..................>

Register AzureContainer

Go to azure console and create container "avatars". Now we can create an AzureContainer resource:

POST /AzureContainer
id: avatars
account: {id: aidbox, resourceType: AzureAccount}
storage: aidbox
container: avatars

Get SAS to upload file

You can provide blob name or just extension (name will be generated).

POST /azure/storage/avatars
blob: pt-1.png
# extension: png
status: 200

Configure CORS in azure if you want to send data from browser:

Now you can upload file from your UI:

//onChange input[type=file]
var file = inputEvent.file.originFileObj;
fetch("<signed-url>", {
method: 'PUT',
body: file,
headers: {'x-ms-blob-type': 'BlockBlob'}

Get SAS for read

To read uploaded file you can request signed url with:

GET /azure/storage/avatar/pt-1.png
status: 200
url: <read-signed-url>
# or
GET /azure/storage/avatar/pt-1.png?redirect=true
status: 302
Locaiton: <read-signed-url>

For example you can use trick with redirect to render image:

<img src="/azure/storage/avatar/pt-1.png?redirect=true"/>