Last active
February 4, 2018 01:38
-
-
Save jjgriff93/8e948234d94197c21556e6eac3646ca0 to your computer and use it in GitHub Desktop.
Azure .NET mgmt API - program.cs to create VM
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| using Microsoft.Azure.Management.Compute.Fluent; | |
| using Microsoft.Azure.Management.Compute.Fluent.Models; | |
| using Microsoft.Azure.Management.Fluent; | |
| namespace FluentAPIApp | |
| { | |
| class Program | |
| { | |
| static void Main(string[] args) | |
| { | |
| var azure = Azure.Authenticate("Azure-authentication.txt").WithDefaultSubscription(); | |
| Console.WriteLine("Creating a new VM..."); | |
| var windowsVM = azure.VirtualMachines.Define("VMCreatedWithFluent") | |
| .WithRegion("West Europe") | |
| .WithNewResourceGroup("FluentRG") | |
| .WithNewPrimaryNetwork("10.0.0.0/28") | |
| .WithPrimaryPrivateIPAddressDynamic() | |
| .WithNewPrimaryPublicIPAddress("fluentdns") | |
| .WithPopularWindowsImage(KnownWindowsVirtualMachineImage.WindowsServer2012Datacenter) | |
| .WithAdminUsername("serverAdmin") | |
| .WithAdminPassword("mySuperSecurePassword18") | |
| .WithSize(VirtualMachineSizeTypes.StandardDS3V2) | |
| .Create(); | |
| Console.WriteLine("Successfully created a new VM: {0}!", windowsVM.Id); | |
| Console.WriteLine("Press any key to exit..."); | |
| Console.ReadLine(); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment