Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
484 views
in Technique[技术] by (71.8m points)

powershell - VNet not found when attempting to create VNET integration via azureRM

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:UsersAndreDesktopReposdevops-scriptingandre-script-remakeclusterswap.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?

question from:https://stackoverflow.com/questions/65877742/vnet-not-found-when-attempting-to-create-vnet-integration-via-azurerm

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

  1. If your resources are in the same region, then you could avoid additional costs associated with Gateways, by using Regional VNet Integration. This is super easy to setup. The CLI is available here
  2. There is also NAT Gateway. See this for provisioning NAT Gateways

HTH


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...