Reputation: 379
I am attempting to configure the VNET of an app service. I am attempting to do this via a powershell script. I have been using the same powershell script for over a year and it has suddenly stopped working without any modifications to the script. The link that is failing is as follows:
$propertiesObject = @{
"vnetResourceId" = "/subscriptions/$($subscriptionId)/resourceGroups/$($vnetToaddResGroup)/providers/Microsoft.Network/virtualNetworks/$($vnetToAdd)"
}
New-AzureRmResource -Location $location -Properties $propertiesObject -ResourceName "$($WebApp)/$($vnetToAdd)/primary" -ResourceType "Microsoft.Web/sites/virtualNetworkConnections/gateways" -ApiVersion 2015-08-01 -ResourceGroupName $WebAppResourceGroup -Force
This then results in the following error:
New-AzureRmResource : {"Code":"NotFound","Message":"Cannot find Vnet with name
VNet-EUDEV02.","Target":null,"Details":[{"Message":"Cannot find Vnet with name
VNet-EUDEV02."},{"Code":"NotFound"},{"ErrorEntity":{"ExtendedCode":"51004","MessageTemplate":"Cannot find {0} with
name {1}.","Parameters":["Vnet","VNet-EUDEV02"],"Code":"NotFound","Message":"Cannot find Vnet with name
VNet-EUDEV02."}}],"Innererror":null}
At C:\Users\Andre\Desktop\Repos\devops-scripting\andre-script-remake\clusterswap.ps1:66 char:5
+ New-AzureRmResource -Location $location -Properties $propertiesOb ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [New-AzureRmResource], ErrorResponseMessageException
+ FullyQualifiedErrorId : NotFound,Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourc
eCmdlet
This is strange as I have checked the VNET exists, and also checked the the resource group, and have tried numerous other Vnets.
How can I add VNet integration via a powershell command using azureRM?
Upvotes: 0
Views: 724
Reputation: 2467
This command is trying to use Gateway-required VNet Integration. I guess you already have a gateway provisioned and intend to use it.
Looking at the command, one thing which stands out is this parameter
-ResourceName "$($WebApp)/$($vnetToAdd)/primary"
Refer this post on how to do this.
Additionally, there is a PS script here that can be used to provision the VPN gateway and then configure it with the Web App.
BTW, there are other options to consider.
HTH
Upvotes: 0