#Azure Management Libraries for .NET
This README is based on the latest released preview version (1.0 beta 5). 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.
1.0 beta 5 is a developer preview that supports major parts of:
- Azure Virtual Machines and VM Extensions
- Virtual Machine Scale Sets
- Managed Disks
- Storage
- Networking (virtual networks, subnets, network interfaces, IP addresses, network security groups, load balancers, DNS, traffic managers and application gateways)
- Resource Manager
- SQL Database (databases, firewalls and elastic pools)
- App Service (Web Apps)
- Key Vault, Redis, CDN and Batch.
The next preview version of the Azure Management Libraries for .NET is a work in-progress. We will be adding support for more Azure services and applying finishing touches to the API.
Azure Authentication
The Azure
class is the simplest entry point for creating and interacting with Azure resources.
Azure azure = Azure.Authenticate(credFile).WithDefaultSubscription();
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.US_EAST)
.WithNewResourceGroup(rgName)
.WithNewPrimaryNetwork("10.0.0.0/28")
.WithPrimaryPrivateIpAddressDynamic()
.WithNewPrimaryPublicIpAddress("mywindowsvmdns")
.WithPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_R2_DATACENTER)
.WithAdminUsername("tirekicker")
.WithPassword(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, dataDiskName, 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.US_EAST)
.WithExistingResourceGroup(rgName)
.WithSku(VirtualMachineScaleSetSkuTypes.STANDARD_D3_V2)
.WithExistingPrimaryNetworkSubnet(network, "Front-end")
.WithPrimaryInternetFacingLoadBalancer(loadBalancer1)
.WithPrimaryInternetFacingLoadBalancerBackends(backendPoolName1, backendPoolName2)
.WithPrimaryInternetFacingLoadBalancerInboundNatPools(natPool50XXto22, natPool60XXto23)
.WithoutPrimaryInternalLoadBalancer()
.WithPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_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.US_EAST)
.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.US_EAST)
.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)
.WithNewResourceGroup(rgName)
.WithNewAppServicePlan(planName)
.WithRegion(Region.US_WEST)
.WithPricingTier(AppServicePricingTier.STANDARD_S1)
.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.US_EAST)
.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 in Azure Virtual Machines, Virtual Machine Scale Sets, Managed Disks, Storage, Networking, Resource Manager, SQL Database, App Service (Web Apps), Key Vault, Redis, CDN and Batch …
Service | Management Scenario |
---|---|
Virtual Machines |
|
Virtual Machines - parallel execution | |
Virtual Machine Scale Sets | |
Storage | |
Networking | |
Networking - DNS | |
Traffic Manager | |
Application Gateway | |
SQL Database | |
Redis Cache | |
App Service - Web Apps | |
Resource Groups | |
Key Vault | |
CDN | |
Batch |
1.0 beta 5
1.0 beta 5 release builds are available on NuGet:
Azure Management Library | Package name | Stable (1.0 beta 5 release)
-----------------------|-------------------------------------------|-----------------------------|-------------------------
Azure Management Client (wrapper package) | Microsoft.Azure.Management.Fluent
|
App Service (Web Apps) | Microsoft.Azure.Management.AppService.Fluent
|
Batch | Microsoft.Azure.Management.Batch.Fluent
|
CDN | Microsoft.Azure.Management.Cdn.Fluent
|
Virtual Machines & Virtual Machine Scale Sets | Microsoft.Azure.Management.Compute.Fluent
|
DNS | Microsoft.Azure.Management.Dns.Fluent
|
Key Vault |Microsoft.Azure.Management.KeyVault.Fluent
|
Networking |Microsoft.Azure.Management.Network.Fluent
|
Redis Cache |Microsoft.Azure.Management.Redis.Fluent
|
Resource Manager |Microsoft.Azure.Management.ResourceManager.Fluent
|
SQL Database |Microsoft.Azure.Management.Sql.Fluent
|
Storage |Microsoft.Azure.Management.Storage.Fluent
|
Traffic Manager |Microsoft.Azure.Management.TrafficManager.Fluent
|
#Pre-requisites
- .NET Core
- Azure Service Principal - see how to create authentication info.
If you are migrating your code to 1.0 beta 5, you can use these notes for preparing your code for 1.0 beta 5 from 1.0 beta 4.
If you encounter any bugs with these libraries, please file issues via Issues and tag them Fluent or checkout StackOverflow for Azure Management Libraries for .NET.
#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.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.