gpt4 book ai didi

azure - 如何在没有 NSG 的情况下创建 Azure VM?

转载 作者:行者123 更新时间:2023-12-03 06:54:09 28 4
gpt4 key购买 nike

我想创建一个没有 nsg 的虚拟机。在 New-AzVm cmdlet 中,我在 PublicIP 参数中指定 $null - 并且它有效(即它不会创建公共(public) IP)。但这不适用于 nsg。这是我的代码:

$Date = Get-Date -Format "MMddyymm"
$user = "Sitecore"
$password = ConvertTo-SecureString "Qwerty123456" -AsPlainText -Force
$credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $user, $password
$RGroup = 'test'
$Location = "Westus3"
$VMName = "vmtest$date"
$image = "vmtest-image-20220805165444"
$vnet = "vnet1"
$NSG = "nsg$date"
$SizeVM = "Standard_b4ms"
$NIC = "$VMName$date"
$Subnet = "default"
$tags = @{'xxx' = 'yyy'}

New-AzVM -ResourceGroupName $RGroup `
-Name $VMName `
-Image $image `
-Location $Location `
-VirtualNetworkName $vnet `
-SubnetName $Subnet `
-SecurityGroupName $null `
-PublicIpAddressName $null `
-Credential $credential `
-Size $SizeVM

最佳答案

当我们使用 new-azvm cmdlet 时,它不起作用。相反,创建一个没有 NSG 的虚拟机。只有 Azure CLI 可以执行此操作:

az vm create --nsg '""' 

关于azure - 如何在没有 NSG 的情况下创建 Azure VM?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73266837/

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