/// <summary>
 /// Create ubuntu server 16.04 LTS vm
 /// </summary>
 public static Task <IVirtualMachineResource> CreateXenialAsync(
     this IVirtualMachineFactory service, IResourceGroupResource resourceGroup,
     string name = null, INetworkResource network = null, string customData = null)
 {
     return(service.CreateAsync(resourceGroup, name, network, KnownImages.Ubuntu_16_04_lts,
                                customData));
 }
        /// <summary>
        /// Get or create new vm in a resource group.
        /// </summary>
        /// <param name="service"></param>
        /// <param name="resourceGroup"></param>
        /// <param name="name"></param>
        /// <param name="network"></param>
        /// <param name="image"></param>
        /// <returns></returns>
        public static async Task <IVirtualMachineResource> GetOrCreateAsync(
            this IVirtualMachineFactory service, IResourceGroupResource resourceGroup,
            string name, INetworkResource network = null, VirtualMachineImage image = null)
        {
            var resource = await Try.Async(() => service.GetAsync(resourceGroup, name));

            if (resource == null)
            {
                resource = await service.CreateAsync(resourceGroup, name, network, image, null);
            }
            return(resource);
        }
 /// <summary>
 /// Create a new linux virtual machine
 /// </summary>
 public static Task <IVirtualMachineResource> CreateAsync(
     this IVirtualMachineFactory service, IResourceGroupResource resourceGroup,
     string name, VirtualMachineImage image) =>
 service.CreateAsync(resourceGroup, name, null, image, null);
 /// <summary>
 /// Create a new linux virtual machine
 /// </summary>
 public static Task <IVirtualMachineResource> CreateAsync(
     this IVirtualMachineFactory service, IResourceGroupResource resourceGroup,
     string name = null, INetworkResource network = null, string customData = null) =>
 service.CreateAsync(resourceGroup, name, network, null, customData);