GitHub - Azure/azure-libraries-for-net: Azure libraries for .Net (original) (raw)

Build Status

This Repository was Deprecated in September 2022

Thank you for the interest in this package.

If you are looking for the latest packages to interact with Azure resources, please use the following libraries:https://aka.ms/azsdk/dotnet/mgmt

Here is all of the latest packages: https://azure.github.io/azure-sdk/releases/latest/mgmt/dotnet.html

You can refer to this https://aka.ms/dotnet/t2/migration for more details about how to migrate your current code to our new SDK.

Azure Management Libraries for .NET

This README is based on the released stable version (1.38.1). If you are looking for other releases, see More Information

The Azure Management Libraries for .NET is a higher-level, object-oriented API for managing Azure resources. Libraries are built on the lower-level, request-response style auto generated clients and can run side-by-side with auto generated clients.

Table of contents

Feature Availability and Road Map

🚩 as of Version 1.38.1

Service | feature Available as GA Available as Preview Coming soon
Compute Virtual machines and VM extensionsVirtual machine scale setsManaged disks Azure container service (AKS) + registry + instancesAvailability Zones More Availability Zones and MSI features
Storage Storage accountsEncryption (deprecated) Encryption (Blob)Encryption (File)
SQL Database DatabasesFirewalls and virtual networkElastic poolsImport, export, recover and restore dbsFailover groups and replication linksDNS aliasing and metricsSync groupsEncryption protectors More features
Networking Virtual networksNetwork interfacesIP addressesRouting tableNetwork security groupsLoad balancersApplication gatewaysDNSTraffic managers Network peeringVirtual Network GatewayNetwork watchersExpress RouteApplication Security Groups More application gateway features
More services Resource ManagerKey VaultRedisCDNService bus Web appsFunction AppsGraph RBACCosmos DBMonitorBatch AISearchEvent Hub Data LakeMore Monitor featuresLogic AppsEvent Grid
Fundamentals Authentication - coreAsync methodsManaged Service Identity

Preview features are flagged in documentation comments in libraries. These features are subject to change. They can be modified in any way, or even removed, in the future.

Code snippets and samples

Azure Authentication

The Azure class is the simplest entry point for creating and interacting with Azure resources.

IAzure azure = Azure.Authenticate(credFile).WithDefaultSubscription();

To learn more about authentication in the Azure Libraries for .Net, see AUTH.md.

Virtual Machines

Create a Virtual Machine

You can create a virtual machine instance by using a Define() … Create() method chain.

Console.WriteLine("Creating a Windows VM");

var windowsVM = azure.VirtualMachines.Define("myWindowsVM") .WithRegion(Region.USEast) .WithNewResourceGroup(rgName) .WithNewPrimaryNetwork("10.0.0.0/28") .WithPrimaryPrivateIPAddressDynamic() .WithNewPrimaryPublicIPAddress("mywindowsvmdns") .WithPopularWindowsImage(KnownWindowsVirtualMachineImage.WindowsServer2012R2Datacenter) .WithAdminUsername("tirekicker") .WithAdminPassword(password) .WithSize(VirtualMachineSizeTypes.StandardD3V2) .Create();

Console.WriteLine("Created a Windows VM: " + windowsVM.Id);

Update a Virtual Machine

You can update a virtual machine instance by using an Update() … Apply() method chain.

windowsVM.Update() .WithNewDataDisk(20, lun, CachingTypes.ReadWrite) .Apply();

Create a Virtual Machine Scale Set

You can create a virtual machine scale set instance by using another Define() … Create() method chain.

var virtualMachineScaleSet = azure.VirtualMachineScaleSets.Define(vmssName) .WithRegion(Region.USEast) .WithExistingResourceGroup(rgName) .WithSku(VirtualMachineScaleSetSkuTypes.StandardD3v2) .WithExistingPrimaryNetworkSubnet(network, "Front-end") .WithPrimaryInternetFacingLoadBalancer(loadBalancer1) .WithPrimaryInternetFacingLoadBalancerBackends(backendPoolName1, backendPoolName2) .WithPrimaryInternetFacingLoadBalancerInboundNatPools(natPool50XXto22, natPool60XXto23) .WithoutPrimaryInternalLoadBalancer() .WithPopularLinuxImage(KnownLinuxVirtualMachineImage.UbuntuServer16_04_Lts) .WithRootUsername(userName) .WithSsh(sshKey) .WithNewDataDisk(100) .WithNewDataDisk(100, 1, CachingTypes.ReadWrite) .WithNewDataDisk(100, 2, CachingTypes.ReadWrite, StorageAccountTypes.StandardLRS) .WithCapacity(3) .Create();

Ready-to-run code samples for virtual machines

Service Management Scenario
Virtual Machines Manage virtual machines Manage virtual machines asynchronously Manage availability set List virtual machine images Manage virtual machines using VM extensions List virtual machine extension images Create virtual machines from generalized image or specialized VHD Create virtual machine using custom image from virtual machine Create virtual machine using custom image from VHD Create virtual machine by importing a specialized operating system disk VHD Create virtual machine using specialized VHD from snapshot Convert virtual machines to use managed disks Manage virtual machine with unmanaged disks Manage virtual machine with disks Manage virtual machine with managed disks Manage Azure resources from a virtual machine with system assigned managed service identity (MSI) Manage Azure resources from a virtual machine with managed service identity (MSI) credentials Manage Azure resources from a virtual machine with system assigned managed service identity (MSI) Manage virtual machines in availability zones Manage virtual machine scale sets in availability zones List compute SKUs
Virtual Machines - parallel execution Create multiple virtual machines in parallel Create multiple virtual machines with network in parallel Create multiple virtual machines across regions in parallel
Virtual Machine Scale Sets Manage virtual machine scale sets (behind an Internet facing load balancer) Manage virtual machine scale sets (behind an Internet facing load balancer) asynchronously Manage virtual machine scale sets with unmanaged disks

Networking

Create a virtual network

You can create a virtual network by using a define() … create() method chain.

var network = networks.Define("mynetwork") .WithRegion(Region.USEast) .WithNewResourceGroup() .WithAddressSpace("10.0.0.0/28") .WithSubnet("subnet1", "10.0.0.0/29") .WithSubnet("subnet2", "10.0.0.8/29") .Create();

Create a Network Security Group

You can create a network security group instance by using another Define() … Create() method chain.

var frontEndNSG = azure.NetworkSecurityGroups.Define(frontEndNSGName) .WithRegion(Region.USEast) .WithNewResourceGroup(rgName) .DefineRule("ALLOW-SSH") .AllowInbound() .FromAnyAddress() .FromAnyPort() .ToAnyAddress() .ToPort(22) .WithProtocol(SecurityRuleProtocol.Tcp) .WithPriority(100) .WithDescription("Allow SSH") .Attach() .DefineRule("ALLOW-HTTP") .AllowInbound() .FromAnyAddress() .FromAnyPort() .ToAnyAddress() .ToPort(80) .WithProtocol(SecurityRuleProtocol.Tcp) .WithPriority(101) .WithDescription("Allow HTTP") .Attach() .Create();

Create an Application Gateway

You can create a application gateway instance by using another define() … create() method chain.

var applicationGateway = azure.ApplicationGateways.Define("myFirstAppGateway") .WithRegion(Region.USEast) .WithExistingResourceGroup(resourceGroup) // Request routing rule for HTTP from public 80 to public 8080 .DefineRequestRoutingRule("HTTP-80-to-8080") .FromPublicFrontend() .FromFrontendHttpPort(80) .ToBackendHttpPort(8080) .ToBackendIPAddress("11.1.1.1") .ToBackendIPAddress("11.1.1.2") .ToBackendIPAddress("11.1.1.3") .ToBackendIPAddress("11.1.1.4") .Attach() .WithExistingPublicIPAddress(publicIpAddress) .Create();

Ready-to-run code samples for networking

Service Management Scenario
Networking Manage virtual network Manage virtual network asynchronously Manage network interface Manage network security group Manage IP address Manage Internet facing load balancers Manage internal load balancers Create simple Internet facing load balancer Use net watcher Manage network peering between two virtual networks Use network watcher to check connectivity between virtual machines in peered networks Manage virtual network with site-to-site VPN connection Manage virtual network to virtual network VPN connection Manage client to virtual network VPN connection Create simple Internet facing load balancers
DNS Host and manage domains
Private DNS Host and manage domains with Private DNS
Traffic Manager Manage traffic manager profiles
Application Gateway Manage application gateways Manage application gateways with backend pools
Express Route Create and configure Express Route

Application Services

Create a Web App

You can create a Web App instance by using another define() … create() method chain.

var webApp = azure.WebApps.Define(appName) .WithRegion(Region.USWest) .WithNewResourceGroup(rgName) .WithNewWindowsPlan(PricingTier.StandardS1) .Create();

Ready-to-run code samples for Application Services

Service Management Scenario
Web Apps on Windows Manage Web apps Manage Web apps with custom domains Configure deployment sources for Web apps Configure deployment sources for Web apps asynchronously Manage staging and production slots for Web apps Scale Web apps Manage storage connections for Web apps Manage data connections (such as SQL database and Redis cache) for Web apps Manage authentication for Web apps Safeguard Web app secrets in Key Vault Get logs for Web apps
Web Apps on Linux Manage Web apps Manage Web apps with custom domains Configure deployment sources for Web apps Scale Web apps Manage storage connections for Web apps Manage data connections (such as SQL database and Redis cache) for Web apps
Functions Manage functions Manage functions with custom domains Configure deployment sources for functions Manage authentication for functions Get function logs

Databases and Storage

Create a Cosmos DB with CosmosDB Programming Model

You can create a Cosmos DB account by using a define() … create() method chain.

var documentDBAccount = azure.CosmosDBAccounts.Define(cosmosDBName) .WithRegion(Region.USEast) .WithNewResourceGroup(rgName) .WithKind(DatabaseAccountKind.GlobalDocumentDB) .WithSessionConsistency() .WithWriteReplication(Region.USWest) .WithReadReplication(Region.USCentral) .Create();

Create a SQL Database

You can create a SQL server instance by using another define() … create() method chain.

var sqlServer = azure.SqlServers.Define(sqlServerName) .WithRegion(Region.USEast) .WithNewResourceGroup(rgName) .WithAdministratorLogin(administratorLogin) .WithAdministratorPassword(administratorPassword) .WithNewFirewallRule(firewallRuleIpAddress) .WithNewFirewallRule(firewallRuleStartIpAddress, firewallRuleEndIpAddress) .Create();

Then, you can create a SQL database instance by using another define() … create() method chain.

var database = sqlServer.Databases.Define(databaseName) .Create();

Ready-to-run code samples for databases

Service Management Scenario
Storage Manage storage accounts Manage storage accounts asynchronously Manage network rules of a storage account
SQL Database Manage SQL databases Manage SQL databases in elastic pools Manage firewalls for SQL databases Manage SQL databases across regions Import and export SQL databases Restore and recover SQL databases Get SQL Database metrics Manage SQL Database Failover Groups Manage SQL Server DNL aliases Manage SQL secrets (Server Keys) in Azure Key Vault Manage SQL Virtual Network Rules
Cosmos DB Create a CosmosDB and configure it for high availability Create a CosmosDB and configure it with eventual consistency Create a CosmosDB, configure it for high availability and create a firewall to limit access from an approved set of IP addresses Create a CosmosDB and get MongoDB connection string Create a CosmosDB configured with a virtual network rule

Other code samples

Service Management Scenario
Active Directory Manage service principals using .NET Manage users and groups and manage their roles Manage passwords Manage Azure resources from a managed service identity (MSI) enabled virtual machine that belongs to an Azure Active Directory (AAD) security group
Container ServiceContainer Registry and Container Instances Manage container registry Manage container registry with Web hooks Manage Kubernetes cluster (AKS) Manage container service with Kubernetes orchestration Manage container service with Docker Swarm orchestration Create Container Group using images from a private registry Manage Azure Container Instances with new Azure File Share Manage Azure Container Instances with an existing Azure File Share Create Container Group with multiple instances and container images
Service Bus Manage queues with basic features Manage publish-subscribe with basic features Manage queues and publish-subcribe with cliams based authorization Manage publish-subscribe with advanced features - sessions, dead-lettering, de-duplication and auto-deletion of idle entries Manage queues with advanced features - sessions, dead-lettering, de-duplication and auto-deletion of idle entries
Resource Groups Manage resource groups Manage resources Manage resource locks Deploy resources with ARM templates Deploy resources with ARM templates (with progress) Deploy a virtual machine with managed disks using an ARM template Manage policy assignment Manage policy definition
Redis Cache Manage Redis Cache
Key Vault Manage key vaults
Monitor Get metrics and activity logs for a resource Stream Azure Service Logs and Metrics for consumption through Event Hub Configuring activity log alerts to be triggered on potential security breaches or risks. Configuring metric alerts to be triggered on potential performance downgrade. Configuring autoscale settings to scale out based on webapp request count statistic.
CDN Manage CDNs
Batch AI Create Batch AI cluster and execute AI job
Search Manage Azure search
Event Hub Manage event hub and associated resources Manage event hub geo-disaster recovery Stream Azure Service Logs and Metrics for consumption through Event Hub

Logging

Logging can be enabled by providing an implementation of IServiceClientTracingInterceptor interface.

ServiceClientTracing.AddTracingInterceptor(new LoggingTracer()); ServiceClientTracing.IsEnabled = true;

IAzure azure = Azure.Configure().WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic) .Authenticate(credFile).WithDefaultSubscription();

Download

Latest stable release

1.38.1 release builds are available on NuGet:

Azure Management Library Package name Stable
Azure Management Client (wrapper package) Microsoft.Azure.Management.Fluent NuGet
App Service (Web Apps and Functions) Microsoft.Azure.Management.AppService.Fluent NuGet
Batch AI Microsoft.Azure.Management.BatchAI.Fluent NuGet
CDN Microsoft.Azure.Management.Cdn.Fluent NuGet
Virtual Machines, Virtual Machine Scale Sets, Azure Container Services Microsoft.Azure.Management.Compute.Fluent NuGet
Container Instance Microsoft.Azure.Management.ContainerInstance.Fluent NuGet
Container Registry Microsoft.Azure.Management.ContainerRegistry.Fluent NuGet
Container Service Microsoft.Azure.Management.ContainerService.Fluent NuGet
Cosmos DB Microsoft.Azure.Management.CosmosDB.Fluent NuGet
DNS Microsoft.Azure.Management.Dns.Fluent NuGet
EventHub Microsoft.Azure.Management.EventHub.Fluent NuGet
Graph RBAC Microsoft.Azure.Management.Graph.RBAC.Fluent NuGet
Key Vault Microsoft.Azure.Management.KeyVault.Fluent NuGet
Locks Microsoft.Azure.Management.Locks.Fluent NuGet
Monitor Microsoft.Azure.Management.Monitor.Fluent NuGet
Msi Microsoft.Azure.Management.Msi.Fluent NuGet
Networking Microsoft.Azure.Management.Network.Fluent NuGet
Redis Cache Microsoft.Azure.Management.Redis.Fluent NuGet
Resource Manager Microsoft.Azure.Management.ResourceManager.Fluent NuGet
Search Microsoft.Azure.Management.Search.Fluent NuGet
Service Bus Microsoft.Azure.Management.ServiceBus.Fluent NuGet
SQL Database Microsoft.Azure.Management.Sql.Fluent NuGet
Storage Microsoft.Azure.Management.Storage.Fluent NuGet
Traffic Manager Microsoft.Azure.Management.TrafficManager.Fluent NuGet

Prerequisites

Upgrading from older versions

If you are migrating your code from 1.38.0 to 1.38.1, you can use these release notes for preparing your code for 1.38.1 from 1.38.0.

In general, Azure Libraries for .Net follow semantic versioning, so user code should continue working in a compatible fashion between minor versions of the same major version release train, with the following caveats:

Help and Issues

If you encounter any bugs with these libraries, please file issues via Issues or checkout StackOverflow for Azure Management Libraries for .NET.

To enable Http message tracing in your code please check logging.

Contribute Code

If you would like to become an active contributor to this project please follow the instructions provided in Microsoft Azure Projects Contribution Guidelines.

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

More Information

Previous Releases and Corresponding Repo Branches

Version SHA1 Remarks
1.38.1 1.38.1 Tagged release for 1.38.1 version of Azure management libraries
1.38 1.38 Tagged release for 1.38 version of Azure management libraries
1.37.1 1.37.1 Tagged release for 1.37.1 version of Azure management libraries
1.37 1.37 Tagged release for 1.37 version of Azure management libraries
1.36.1 1.36.1 Tagged release for 1.36.1 version of Azure management libraries
1.36 1.36 Tagged release for 1.36 version of Azure management libraries
1.35 1.35 Tagged release for 1.35 version of Azure management libraries
1.34 1.34 Tagged release for 1.34 version of Azure management libraries
1.33 1.33 Tagged release for 1.33 version of Azure management libraries
1.32 1.32 Tagged release for 1.32 version of Azure management libraries
1.31.1 1.31.1 Tagged release for 1.31.1 version of Azure management libraries
1.31 1.31 Tagged release for 1.31 version of Azure management libraries
1.30 1.30 Tagged release for 1.30 version of Azure management libraries
1.29.1 1.29.1 Tagged release for 1.29.1 version of Azure management libraries
1.29 1.29 Tagged release for 1.29 version of Azure management libraries
1.28.1 1.28.1 Tagged release for 1.28.1 version of Azure management libraries
1.28 1.28 Tagged release for 1.28 version of Azure management libraries
1.27.2 1.27.2 Tagged release for 1.27.2 version of Azure management libraries
1.27 1.27 Tagged release for 1.27 version of Azure management libraries
1.26.1 1.26.1 Tagged release for 1.26.1 version of Azure management libraries
1.26 1.26 Tagged release for 1.26 version of Azure management libraries
1.25 1.25 Tagged release for 1.25 version of Azure management libraries
1.24 1.24 Tagged release for 1.24 version of Azure management libraries
1.23 1.23 Tagged release for 1.23 version of Azure management libraries
1.22 1.22 Tagged release for 1.22 version of Azure management libraries
1.21 1.21 Tagged release for 1.21 version of Azure management libraries
1.20 1.20 Tagged release for 1.20 version of Azure management libraries
1.19 1.19 Tagged release for 1.19 version of Azure management libraries
1.18 1.18 Tagged release for 1.18 version of Azure management libraries
1.17 1.17 Tagged release for 1.17 version of Azure management libraries
1.16 1.16 Tagged release for 1.16 version of Azure management libraries
1.15 1.15 Tagged release for 1.15 version of Azure management libraries
1.14 1.14 Tagged release for 1.14 version of Azure management libraries
1.13 1.13 Tagged release for 1.13 version of Azure management libraries
1.11 1.11 Tagged release for 1.11 version of Azure management libraries
1.10 1.10 Tagged release for 1.10 version of Azure management libraries
1.9 1.9 Tagged release for 1.9 version of Azure management libraries
1.8 1.8 Tagged release for 1.8 version of Azure management libraries
1.7 1.7 Tagged release for 1.7 version of Azure management libraries
1.6 1.6 Tagged release for 1.6 version of Azure management libraries
1.4 1.4 Tagged release for 1.4 version of Azure management libraries
1.3 1.3 Tagged release for 1.3 version of Azure management libraries
1.2 1.2 Tagged release for 1.2 version of Azure management libraries
1.1 1.1 Tagged release for 1.1 version of Azure management libraries
1.0 1.0 Tagged release for 1.0 version of Azure management libraries
1.0.0-beta5 1.0.0-beta5 Tagged release for 1.0.0-beta5 version of Azure management libraries
1.0.0-beta4 1.0.0-beta4 Tagged release for 1.0.0-beta4 version of Azure management libraries
1.0.0-beta3 1.0.0-beta3 Tagged release for 1.0.0-beta3 version of Azure management libraries
AutoRest AutoRest Main branch for AutoRest generated raw clients

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.