Пример #1
0
        /// <summary>
        /// Construct an object used to create a VirtualMachine.
        /// </summary>
        /// <param name="vmName"> The name of the Virtual Machine. </param>
        /// <param name="adminUser"> The admin username to use. </param>
        /// <param name="adminPw"> The admin password to use. </param>
        /// <param name="nicId"> The network interface id to use. </param>
        /// <param name="aset"> The availability set to use. </param>
        /// <param name="location"> The location to create the Virtual Machine. </param>
        /// <returns> Object used to create a <see cref="VirtualMachine"/>. </returns>
        public VirtualMachineModelBuilder Construct(string vmName, string adminUser, string adminPw, ResourceIdentifier nicId, AvailabilitySetData aset, Location location = null)
        {
            Console.WriteLine("\n-----------------------\nVM NAME IS : " + vmName + "\n----------------------------------\n");
            var vm = new Azure.ResourceManager.Compute.Models.VirtualMachine(location ?? DefaultLocation)
            {
                NetworkProfile = new NetworkProfile {
                    NetworkInterfaces = new[] { new NetworkInterfaceReference()
                                                {
                                                    Id = nicId
                                                } }
                },
                OsProfile = new OSProfile
                {
                    ComputerName         = vmName,
                    AdminUsername        = adminUser,
                    AdminPassword        = adminPw,
                    WindowsConfiguration = new WindowsConfiguration {
                        TimeZone = "Pacific Standard Time", ProvisionVMAgent = true
                    }
                },
                StorageProfile = new StorageProfile()
                {
                    ImageReference = new ImageReference()
                    {
                        Offer     = "WindowsServer",
                        Publisher = "MicrosoftWindowsServer",
                        Sku       = "2019-Datacenter",
                        Version   = "latest"
                    },
                    DataDisks = new List <DataDisk>()
                },
                HardwareProfile = new HardwareProfile()
                {
                    VmSize = VirtualMachineSizeTypes.StandardB1Ms
                },
                AvailabilitySet = new SubResource()
                {
                    Id = aset.Id
                }
            };

            return(new VirtualMachineModelBuilder(this, new VirtualMachineData(vm)));
        }
Пример #2
0
        /// <summary>
        /// Construct an object used to create a VirtualMachine.
        /// </summary>
        /// <param name="hostName"> The hostname for the virtual machine. </param>
        /// <param name="adminUser"> The admin username to use. </param>
        /// <param name="adminPassword"> The admin password to use. </param>
        /// <param name="networkInterfaceId"> The network interface id to use. </param>
        /// <param name="availabilitySetId"> The availability set id to use. </param>
        /// <param name="location"> The location to create the Virtual Machine. </param>
        /// <returns> Object used to create a <see cref="VirtualMachine"/>. </returns>
        public VirtualMachineModelBuilder Construct(string hostName, string adminUser, string adminPassword, ResourceIdentifier networkInterfaceId, ResourceIdentifier availabilitySetId, LocationData location = null)
        {
            var parent = GetParentResource <ResourceGroup, ResourceGroupOperations>();
            var vm     = new Azure.ResourceManager.Compute.Models.VirtualMachine(location ?? parent.Data.Location)
            {
                NetworkProfile = new NetworkProfile {
                    NetworkInterfaces = new[] { new NetworkInterfaceReference()
                                                {
                                                    Id = networkInterfaceId
                                                } }
                },
                OsProfile = new OSProfile
                {
                    ComputerName         = hostName,
                    AdminUsername        = adminUser,
                    AdminPassword        = adminPassword,
                    WindowsConfiguration = new WindowsConfiguration {
                        TimeZone = "Pacific Standard Time", ProvisionVMAgent = true
                    }
                },
                StorageProfile = new StorageProfile()
                {
                    ImageReference = new ImageReference()
                    {
                        Offer     = "WindowsServer",
                        Publisher = "MicrosoftWindowsServer",
                        Sku       = "2019-Datacenter",
                        Version   = "latest"
                    },
                    DataDisks = new List <DataDisk>()
                },
                HardwareProfile = new HardwareProfile()
                {
                    VmSize = VirtualMachineSizeTypes.StandardB1Ms
                },
                AvailabilitySet = new SubResource()
                {
                    Id = availabilitySetId
                }
            };

            return(new VirtualMachineModelBuilder(this, new VirtualMachineData(vm)));
        }
Пример #3
0
        /// <summary>
        /// Construct an object used to create a VirtualMachine.
        /// </summary>
        /// <param name="vmName"> The name of the Virtual Machine. </param>
        /// <param name="adminUser"> The admin username to use. </param>
        /// <param name="adminPw"> The admin password to use. </param>
        /// <param name="nicId"> The network interface id to use. </param>
        /// <param name="aset"> The availability set to use. </param>
        /// <param name="location"> The location to create the Virtual Machine. </param>
        /// <returns> Object used to create a <see cref="VirtualMachine"/>. </returns>
        public VirtualMachineModelBuilder Construct(string vmName, string adminUser, string adminPw, ResourceIdentifier nicId, AvailabilitySetData aset, Location location = null)
        {
            var vm = new Azure.ResourceManager.Compute.Models.VirtualMachine(location ?? DefaultLocation)
            {
                NetworkProfile = new NetworkProfile {
                    NetworkInterfaces = new[] { new NetworkInterfaceReference()
                                                {
                                                    Id = nicId
                                                } }
                },
                OsProfile = new OSProfile
                {
                    ComputerName       = vmName,
                    AdminUsername      = adminUser,
                    AdminPassword      = adminPw,
                    LinuxConfiguration = new LinuxConfiguration {
                        DisablePasswordAuthentication = false, ProvisionVMAgent = true
                    }
                },
                StorageProfile = new StorageProfile()
                {
                    ImageReference = new ImageReference()
                    {
                        Offer     = "UbuntuServer",
                        Publisher = "Canonical",
                        Sku       = "18.04-LTS",
                        Version   = "latest"
                    },
                    DataDisks = new List <DataDisk>()
                },
                HardwareProfile = new HardwareProfile()
                {
                    VmSize = VirtualMachineSizeTypes.StandardB1Ms
                },
                AvailabilitySet = new SubResource()
                {
                    Id = aset.Id
                }
            };

            return(new VirtualMachineModelBuilder(this, new VirtualMachineData(vm)));
        }