Skip to content

Latest commit

 

History

History
79 lines (57 loc) · 3.34 KB

File metadata and controls

79 lines (57 loc) · 3.34 KB

Storage

ARM management of storage accounts, keys, and blob containers, plus the Storage Queue data plane (send/receive/delete messages). Full REST path tables: ENDPOINTS.md §10 and §12.

Storage accounts (ARM)

use CodebarAg\MicrosoftAzure\Facades\Azure;

$accounts = Azure::instance()->storageAccounts($subscriptionId, 'my-rg');

$accounts->account('myacct')->get();
$accounts->account('myacct')->createOrUpdate(location: 'westeurope');
$accounts->account('myacct')->delete();

$keys = $accounts->account('myacct')->listKeys();
$accounts->account('myacct')->regenerateKey('key1');

Blob containers

Azure::instance()->storageAccounts($subscriptionId, 'my-rg')
    ->account('myacct')
    ->blobContainers()
    ->createOrUpdate('uploads');

Azure::instance()->storageAccounts($subscriptionId, 'my-rg')
    ->account('myacct')
    ->blobContainers()
    ->setManagementPolicy([/* lifecycle policy rules */]);

Storage tables (ARM control plane)

Created through ARM rather than the table data plane, so a table is provisioned with the same credential, and in the same pass, as the account's containers and queues. Idempotent.

Azure::instance()->storageAccounts($subscriptionId, 'my-rg')
    ->account('myacct')
    ->tables()
    ->createOrUpdate('intaketargets');

Storage Queue data plane

Message bodies are base64-encoded automatically (Azure rejects raw XML-unsafe markup in the message body). API version 2025-05-05.

// Entra ID by default — needs the "Storage Queue Data Contributor" RBAC role
$queue = Azure::instance()->storageAccounts($subscriptionId, 'my-rg')->account('myacct')->queue('orders');

$queue->sendMessage('hello world', visibilityTimeoutSeconds: 0, messageTtlSeconds: 3600);
$messages = $queue->receiveMessages(numberOfMessages: 5);
$queue->deleteMessage($messages->first()->messageId, $messages->first()->popReceipt);
// ...or Shared Key, using an account key from listKeys() instead of Entra ID
$key = Azure::instance()->storageAccounts($subscriptionId, 'my-rg')->account('myacct')->listKeys()->keys[0]['value'];
$queue = Azure::instance()->storageAccounts($subscriptionId, 'my-rg')->account('myacct')->queue('orders', accountKey: $key);

Two distinct auth modes, chosen per call via the optional $accountKey argument on queue():

  • Omit it → Entra ID bearer token (https://storage.azure.com/.default); the caller's service principal needs the Storage Queue Data Contributor RBAC role.
  • Pass an account key (from listKeys()) → Shared Key (Full) request signing, computed per-request via HMAC-SHA256 over the canonicalized headers and resource.

Scope is intentionally narrow: message send/receive/delete only — no queue management, peek, or update-message operations. See Troubleshooting for Shared Key auth failure modes (stale key, clock skew).

Actual-state reads

Azure::instance()->storageAccounts($subscriptionId, 'my-rg')->account('myacct')->observe()->state;

Storage accounts spend real time in ResolvingDNS between Creating and Succeeded, and the account endpoints do not answer until they leave it — that window reports Provisioning, not Available. See Advanced usage.