```html Azure SDK for JavaScript – Services

Azure SDK for JavaScript

Overview

The Azure SDK for JavaScript provides a set of client libraries that make it easy to interact with Azure services from Node.js or browser environments. This section covers the most commonly used service packages, installation instructions, and code samples.

Installation

All packages are published on npm. Choose the service you need and install it with:

npm install @azure/service-name

Example for Azure Storage Blobs:

npm install @azure/storage-blob

Compute – Virtual Machines

Manage Azure Virtual Machines using @azure/arm-compute.

import { ComputeManagementClient } from "@azure/arm-compute";
import { DefaultAzureCredential } from "@azure/identity";

const credential = new DefaultAzureCredential();
const subscriptionId = "";
const client = new ComputeManagementClient(credential, subscriptionId);

async function listVMs() {
  const vms = [];
  for await (const vm of client.virtualMachines.listAll()) {
    vms.push(vm.name);
  }
  return vms;
}

listVMs()
  .then(names => console.log("VMs:", names))
  .catch(err => console.error(err));

Storage – Blob Service

Upload and download blobs with @azure/storage-blob.

import { BlobServiceClient } from "@azure/storage-blob";

const connStr = "";
const containerName = "samples";

async function upload() {
  const blobServiceClient = BlobServiceClient.fromConnectionString(connStr);
  const containerClient = blobServiceClient.getContainerClient(containerName);
  await containerClient.createIfNotExists();

  const blockBlobClient = containerClient.getBlockBlobClient("hello.txt");
  const data = "Hello Azure Blob!";
  await blockBlobClient.upload(data, Buffer.byteLength(data));
  return "Upload successful!";
}

upload()
  .then(msg => console.log(msg))
  .catch(err => console.error(err));

Further Resources

```