1
votes

I'm trying to add an azure deployment slot to a virtual network. Below is the powershell script I'm currently using for adding the webapp to the Vnet, which is working fine:

#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

How do I change the above script to work with the deployment slot of the same webapp? Thanks in advance.

1

1 Answers

0
votes

You could change your code like this. Note the change of ResourceName and ResourceType.

#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