Today, we are announcing the general availability of the new, simplified Azure management libraries for .NET for Compute, Storage, SQL Database, Networking, Resource Manager, Key Vault, Redis, CDN and Batch services.
Azure Management Libraries for .NET are open source – https://github.com/Azure/azure-sdk-for-net/tree/Fluent
Service | Feature | Generally available | Available as preview | Coming Soon |
Compute | Virtual machines and VM extensions Virtual machine scale sets Managed disks |
Azure container services Azure container registry |
|
Storage | Storage accounts | Encryption | |
SQL Database | Databases Firewalls Elastic pools |
||
Networking | Virtual networks Network interfaces IP addresses Routing table Network security groups DNS Traffic managers |
Load balancers Application gateways |
|
More services | Resource Manager Key Vault Redis CDN Batch |
App service – Web apps Functions Service bus |
Monitor Graph RBAC DocumentDB Scheduler |
Fundamentals | Authentication – core | Async methods |
Generally available means that developers can use these libraries in production with full support by Microsoft through GitHub or Azure support channels. Preview features are flagged in documentation comments in libraries.
In Spring 2016, based on .NET developer feedback, we started a journey to simplify the Azure management libraries for .NET. Our goal is to improve the developer experience by providing a higher-level, object-oriented API, optimized for readability and writability. These libraries are built on the lower-level, request-response style auto generated clients and can run side-by-side with auto generated clients.
We announced multiple previews of the libraries. During the preview period, early adopters provided us with valuable feedback and helped us prioritize features and Azure services to be supported. For example, we added support for asynchronous methods and Azure Service Bus.
You can download generally available libraries from nuget.org
Working with the Azure Management Libraries for .NET
One C# statement to authenticate. One statement to create a virtual machine. One statement to modify an existing virtual network … No more guessing about what is required vs. optional vs. non-modifiable.
Azure Authentication
One statement to authenticate and choose a subscription. The Azure class is the simplest entry point for creating and interacting with Azure resources.
IAzure azure = Azure.Authenticate(credFile).WithDefaultSubscription();
Create a Virtual Machine
You can create a virtual machine instance by using the define() … create() method chain.
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();
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 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 (69+ end-to-end scenarios) for Azure.
Start using Azure Management Libraries for .NET today!
Start using these libraries today. It is easy to get started. You can run the samples above.
As always, we like to hear your feedback via comments on this blog or by opening issues in GitHub or via e-mail to az-libs-for-net@microsoft.com.