We released 1.3 of the Azure Management Libraries for .NET. This release adds support for availability zones (in preview).
https://github.com/azure/azure-libraries-for-net
Getting started
You can download 1.3 version of the libraries from:
Create Virtual Machine in Availability Zone
You can create a virtual machine instance in an availability zone by using a define() … create() method chain.
var virtualMachine = azure.VirtualMachines .Define("Linux-VM-in-Availability-Zone") .WithRegion(Region.USEast2) .WithNewResourceGroup(rgName) .WithNewPrimaryNetwork("10.0.0.0/28") .WithPrimaryPrivateIPAddressDynamic() .WithNewPrimaryPublicIPAddress("linux-vm-with-high-availability") .WithPopularLinuxImage(KnownLinuxVirtualMachineImage.UbuntuServer16_04_Lts) .WithRootUsername("tirekicker") .WithSsh(sshKey) // Optional .WithAvailabilityZone(AvailabilityZoneId.Zone_1) .WithSize(VirtualMachineSizeTypes.StandardD3V2) // Create VM .Create();
Create Virtual Machine Scale Set in Availability Zone
You can create a virtual machine scale set instance in an availability zone by using another define() … create() method chain.
var virtualMachineScaleSet = azure.VirtualMachineScaleSets .Define("VM-Scale-Set-in-Availability-Zone") .WithRegion(Region.USEast2) .WithExistingResourceGroup(rgName) .WithSku(VirtualMachineScaleSetSkuTypes.StandardD3v2) .WithExistingPrimaryNetworkSubnet(network, "front-end") .WithExistingPrimaryInternetFacingLoadBalancer(loadBalancer) .WithPrimaryInternetFacingLoadBalancerBackends(backends[0]) .WithPrimaryInternetFacingLoadBalancerInboundNatPools(natpools[0]) .WithoutPrimaryInternalLoadBalancer() .WithPopularLinuxImage(KnownLinuxVirtualMachineImage.UbuntuServer16_04_Lts) .WithRootUsername("tirekicker") .WithSsh(sshKey) // Optional .WithAvailabilityZone(AvailabilityZoneId.Zone_1) // Create VM .Create();
Support for more Azure Services
1.3 also adds support for Network Peering, Virtual Network Gateway and Azure Container Instances.
Peer Two Virtual Networks
You can peer two virtual networks using another define() … create() method chain.
INetworkPeering peeringAB = networkA.Peerings .Define(peeringABName) .WithRemoteNetwork(networkB) .Create();
You can use network watcher to check connectivity between virtual machines in peered virtual networks.
Create Virtual Private Network (VPN) Using Site-to-Site Connection
You can create a virtual private network site-to-site connection using another define() … create() method chain.
virtualNetworkGateway.Connections .Define("My-Connection") .WithSiteToSite() .WithLocalNetworkGateway(localNetworkGateway) .WithSharedKey("MySecretKey") .Create();
You can create a virtual network to virtual network VPN connection.
Create Container Group in Azure Container Instances
You can create a container group with multiple container instances using another define() … create() method chain.
IContainerGroup containerGroup = azure.ContainerGroups .Define("azureContainerInstance") .WithRegion(Region.USWest) .WithNewResourceGroup(rgName) .WithLinux() .WithPublicImageRegistryOnly() .WithoutVolume() .DefineContainerInstance(aciName + "-1") .WithImage(containerImageName1) .WithExternalTcpPort(80) .WithCpuCoreCount(.5) .WithMemorySizeInGB(.75) .Attach() .DefineContainerInstance(aciName + "-2") .WithImage(containerImageName2) .WithoutPorts() .WithCpuCoreCount(.5) .WithMemorySizeInGB(.75) .Attach() .Create();
Similarly, you can:
- Create a container group with a new Azure File Share
- Create a container group with an existing Azure File Share
- Create Container Group using images from a private registry
Try it
You can get more samples from our GitHub repo. Give it a try and let us know what you think (via e-mail or comments below).
You can find plenty of additional info about .NET on Azure at https://docs.microsoft.com/en-us/dotnet/azure/.