Azure部署插槽-使用Powershell将其添加到虚拟网络

时间:2020-09-17 08:32:05

标签: azure powershell azure-powershell

我正在尝试将azure部署插槽添加到虚拟网络。以下是我当前用于将Web应用程序添加到Vnet的powershell脚本,该脚本运行良好:

#Property array with the SubnetID
$properties = @{
  subnetResourceId = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/vnetName/subnets/subnetName"
}

#Creation of the VNet integration
$vnetParams = @{
  ResourceName = "WebappName/VirtualNetwork"
  Location = "South Central US"
  ResourceGroupName = "resourceGroupName"
  ResourceType = "Microsoft.Web/sites/networkConfig"
  PropertyObject = $properties
}
New-AzResource @vnetParams -Force

如何更改以上脚本以使其与同一个Web应用程序的部署插槽配合使用? 预先感谢。

1 个答案:

答案 0 :(得分:0)

您可以像这样更改代码。请注意ResourceNameResourceType的变化。

#Property array with the SubnetID
$properties = @{
  subnetResourceId = "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourceGroupName/providers/Microsoft.Network/virtualNetworks/vnetName/subnets/subnetName"
}

#Creation of the VNet integration
$vnetParams = @{
  ResourceName = "WebappName/slot/VirtualNetwork"
  Location = "South Central US"
  ResourceGroupName = "resourceGroupName"
  ResourceType = "Microsoft.Web/sites/slots/networkConfig"
  PropertyObject = $properties
}
New-AzResource @vnetParams -Force
相关问题