gpt4 book ai didi

Azure,使用保留的IP地址创建VM,并将其放入用户子网中

转载 作者:行者123 更新时间:2023-12-03 00:33:03 25 4
gpt4 key购买 nike

我正在使用静态(保留)IP 地址创建虚拟机

$adminUser = "*****"
$password = "*****"

$reservedIP = "myIP"

# VM Creation Details
$vmName = "*****"
$vmSize = "Small"
$serviceName = "*****"
$location = "West Europe"

$imageFamily = "Windows Server 2012 R2 Datacenter"
$imageName = Get-AzureVMImage |
where { $_.ImageFamily -eq $imageFamily } |
sort PublishedDate -Descending |
select -ExpandProperty ImageName -First 1



# create reserved IP
New-AzureReservedIP – ReservedIPName $reservedIP –Label $reservedIP –Location $location


# Create a virtual machine configuration object
$vm = New-AzureVMConfig -Name $vmName -InstanceSize $vmSize -ImageName $imageName |`
Add-AzureProvisioningConfig -Windows `
-AdminUsername $adminUser `
-Password $password


New-AzureVM -ServiceName $serviceName -Location $location `
-VMs $vm `
-ReservedIPName $reservedIP # Specify the reserved IP address for the external VIP

这里一切正常。

但是我有网络“我的网络”,并且有子网,例如“FrontEndSubnet”。如何将虚拟机放入此子网中?我正在尝试这样

$vm2 = New-AzureVMConfig -Name $vmName -InstanceSize $vmSize -ImageName $imageName |`
Add-AzureProvisioningConfig -Windows `
-AdminUsername $adminUser `
-Password $password | `
Set-AzureSubnet "FrontEndSubnet"

New-AzureVM -ServiceName $serviceName -Location $location `
-VMs $vm2 `
-ReservedIPName $reservedIP # Specify the reserved IP address for the external VIP

但得到

New-AzureVM : BadRequest: The virtual network ID cannot be null or empty.

我尝试用单引号

-Password $password | Set-AzureSubnet 'FrontEndSubnet'

但结果相同。可能吗?

最佳答案

已解决,如本例所示创建:

New-AzureReservedIP –ReservedIPName $reservedIP –Label $reservedIP –Location “West Europe”
Get-AzureReservedIP


# Create a virtual machine configuration object
$vmcfg = New-AzureVMConfig -Name $vmName -InstanceSize $vmSize -ImageName $imageName -Label "WFE name" |`
Set-AzureSubnet "FrontEndSubnet" | `
Add-AzureProvisioningConfig -Windows -AdminUsername $adminUser -Password $password

Test-AzureName -Service $serviceName
# here will be False if servicename is free

New-AzureVM -ServiceName $serviceName -ReservedIPName $reservedIP -Location "West Europe" -VMs $vmcfg -VNetName "MyNetwork"

关于Azure,使用保留的IP地址创建VM,并将其放入用户子网中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27994848/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com