Azure Management Libraries for .NET
This README is based on the released stable version (1.3). 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.
Feature Availability and Road Map as of Version 1.3
Service | feature | Available as GA | Available as Preview | Coming soon |
---|---|---|---|
Compute | Virtual machines and VM extensions Virtual machine scale sets Managed disks |
Azure container service + registry + instances Availability Zones |
More Azure container registry features |
Storage | Storage accounts | Encryption | |
SQL Database | Databases Firewalls Elastic pools |
More features | |
Networking | Virtual networks Network interfaces IP addresses Routing table Network security groups Application gateways DNS Traffic managers |
Load balancers Network peering Virtual Network Gateway Network watchers |
VPN More application gateway features |
More services | Resource Manager Key Vault Redis CDN Batch |
Web apps Function Apps Service bus Graph RBAC Cosmos DB Search |
Monitor Data Lake |
Fundamentals | Authentication - core Async methods Managed 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.
Azure Authentication
The Azure
class is the simplest entry point for creating and interacting with Azure resources.
IAzure azure = Azure.Authenticate(credFile).WithDefaultSubscription();
Create a Cosmos DB with DocumentDB Programming Model
You can create a Cosmos DB account by using a define() … create()
method chain.
var documentDBAccount = azure.DocumentDBAccounts.Define(docDBName)
.WithRegion(Region.USEast)
.WithNewResourceGroup(rgName)
.WithKind(DatabaseAccountKind.GlobalDocumentDB)
.WithSessionConsistency()
.WithWriteReplication(Region.USWest)
.WithReadReplication(Region.USCentral)
.Create();
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")
.WithExistingPrimaryInternetFacingLoadBalancer(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();
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();
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)
.WithNewFreeAppServicePlan()
.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();
Sample Code
You can find plenty of sample code that illustrates management scenarios (95+ end-to-end scenarios) for Azure Virtual Machines, Virtual Machine Scale Sets, Managed Disks, Active Directory Azure Container Service and Registry, Storage, Networking, Resource Manager, SQL Database, Cosmos DB, App Service (Web Apps on Windows and Linux), Functions, Service Bus, Key Vault, Redis, CDN and Batch …
Download
1.3 release builds are available on NuGet:
Pre-requisites
- .NET Core
- Azure Service Principal - see how to create authentication info.
Help
If you are migrating your code to 1.3, you can use these notes for preparing your code for 1.3 from 1.2.
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 this article.
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.
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request
More Information
- https://azure.microsoft.com/en-us/develop/net/
- If you don't have a Microsoft Azure subscription you can get a FREE trial account here.
Previous Releases and Corresponding Repo Branches
Version | SHA1 | Remarks |
---|---|---|
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.