-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathBlobStorageMgt.codeunit.al
More file actions
57 lines (50 loc) · 2.23 KB
/
BlobStorageMgt.codeunit.al
File metadata and controls
57 lines (50 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
codeunit 50101 BlobStorageManagement
{
trigger OnRun()
var
ContainerClient: Codeunit "ABS Container Client";
StorageServiceAuthorization: Codeunit "Storage Service Authorization";
Authorization: Interface "Storage Service Authorization";
Response: Codeunit "ABS Operation Response";
Containers: Record "ABS Container";
BlobClient: Codeunit "ABS Blob Client";
ContainerContent: Record "ABS Container Content";
ContainerContentText: Text;
begin
Authorization := StorageServiceAuthorization.CreateSharedKey(GetSharedKey());
ContainerClient.Initialize('MY_STORAGE_ACCOUNT', Authorization);
//Create container
Response := ContainerClient.CreateContainer('mycontainer');
//List containers
Response := ContainerClient.ListContainers(Containers);
if Response.IsSuccessful() then begin
if Containers.FindSet() then
repeat
message('Container Name: %1', Containers.Name);
until Containers.Next() = 0;
end
else
Message('Error: %1', Response.GetError());
//Init Blob Client
BlobClient.Initialize('MY_STORAGE_ACCOUNT', 'mycontainer', Authorization);
//Create a blob (text content)
Response := BlobClient.PutBlobBlockBlobText('MyBlob', 'This is the content of my blob');
if not Response.IsSuccessful() then
Message('Blob creation error: %1', Response.GetError());
//List blobs
Response := BlobClient.ListBlobs(ContainerContent);
if Response.IsSuccessful() then begin
if ContainerContent.FindSet() then
repeat
Message('ContainerContent Name: %1', ContainerContent.Name);
BlobClient.GetBlobAsText(ContainerContent.Name, ContainerContentText);
Message('%1 content: %2', ContainerContent.Name, ContainerContentText);
//BlobClient.GetBlobAsStream()
//BlobClient.GetBlobAsFile()
until ContainerContent.Next() = 0;
end;
end;
local procedure GetSharedKey(): SecretText
begin
end;
}