Azure Virtual Machine SDK
This documentation provides information on using the Azure Virtual Machine SDK. This SDK allows you to manage Azure Virtual Machines programmatically, automating tasks such as creating, configuring, and deleting virtual machines.
Key Features
- Automation: Automate the creation and management of VMs.
- Infrastructure as Code: Define your VM configurations using code.
- Integration with DevOps Pipelines: Seamless integration with CI/CD pipelines.
- Support for Multiple Languages: Available for C#, PowerShell, and Azure CLI.
Getting Started
To get started, you'll need the Azure SDK for your desired language and an active Azure subscription. Refer to the Quickstart: Create an Azure Virtual Machine for a step-by-step guide.
Example: Creating a Virtual Machine with C#
This example demonstrates how to create an Azure Virtual Machine using the C# SDK.
using Microsoft.Azure.Management.Compute;
using Microsoft.Azure.Management.Compute.Fluent;
// Replace with your Azure subscription credentials
// e.g., using Managed Identity or Service Principal
// ... your credential setup ...
ComputeClient computeClient = new ComputeClient(new AzureTokenCredentials(), new Uri("https://api.azure-apim.com/vm-api/v1"));
await computeClient.VirtualMachines.CreateAsync(
new VirtualMachineCreate()
.WithLocation("East US")
.WithVMName("MyVM")
.WithStorageAccountName("myStorageAccount")
);
Console.WriteLine("Virtual Machine 'MyVM' created successfully!");