Overview
The Azure SDK for JavaScript provides a set of client libraries that make it easy to work with Azure services from Node.js, browser, and React Native applications. These libraries follow Azure's design guidelines, offering consistent authentication, retry policies, and logging across services.
Key Features
- Unified authentication via
@azure/identity - Automatic retries with exponential back‑off
- Built‑in telemetry compatible with Azure Monitor
- Support for Promise‑based async/await patterns
- Typed interfaces with TypeScript definitions
Installation
npm install @azure/arm-storage @azure/identity
Quick Start
// index.js (Node.js)
import { DefaultAzureCredential } from "@azure/identity";
import { StorageManagementClient } from "@azure/arm-storage";
const credential = new DefaultAzureCredential();
const subscriptionId = process.env.AZURE_SUBSCRIPTION_ID;
const client = new StorageManagementClient(credential, subscriptionId);
async function listAccounts() {
const accounts = await client.storageAccounts.list();
for (const acct of accounts) {
console.log(`- ${acct.name} (${acct.location})`);
}
}
listAccounts().catch(console.error);
// index.html (Browser)
<script type="module">
import { DefaultAzureCredential } from "https://cdn.jsdelivr.net/npm/@azure/identity/+esm";
import { StorageManagementClient } from "https://cdn.jsdelivr.net/npm/@azure/arm-storage/+esm";
async function main() {
const credential = new DefaultAzureCredential();
const client = new StorageManagementClient(credential, "");
const accounts = await client.storageAccounts.list();
document.getElementById("output").textContent = JSON.stringify(accounts, null, 2);
}
main().catch(err => console.error(err));
</script>
<pre id="output"></pre>