使用Azure Powershell编写WebApp VNET集成脚本

时间:2016-01-26 11:24:55

标签: azure azure-web-sites azure-powershell

我可以使用azure门户将Web应用程序添加到虚拟网络,以便在其上托管的各种服务之间进行通信。但是我通过Powershell编写了环境中的所有其他内容,并希望自动化WebApp / VNET集成。

到目前为止,我已阅读了以下文章:

https://azure.microsoft.com/en-gb/documentation/articles/web-sites-integrate-with-vnet/

然而,这只是通过门户网站的方式。我认为Set-AzureRMWebApp cmdlet是正确的使用方法,但我看不到任何可能有用的参数。

https://msdn.microsoft.com/en-us/library/mt652487.aspx

3 个答案:

答案 0 :(得分:1)

首先,您需要根据http://www.techdiction.com/2016/01/12/creating-a-point-to-site-vpn-connection-on-an-azure-resource-manager-virtual-network/

上的帖子配置已配置P2S的现有VNet

然后使用以下PowerShell使用P2S VPN将AppService连接到VNet:

$subscription_id = "<Subscription_ID>"
$NetworkName = "<Network_Name>"
$location = "<Region>"
$netrgname = "<Resource_Group_VNet_is_in>"
$AppServiceName = "<AppService_Name>"
 $props = @{
      "vnetResourceId" = "/subscriptions/$subscription_id/resourcegroups/$netrgname/providers/Microsoft.ClassicNetwork/virtualNetworks/$NetworkName";
      "certThumbprint"= "<Client_cert_thumbprint>";
      "certBlob"= "<Base64_Cert_Data>";
      "routes" = $null;
      }

New-AzureRMResource -ResourceName "$AppServiceName/$AppServiceName-to-$NetworkName" -Location $location  -ResourceGroupName MarcusWebsites -ResourceType Microsoft.Web/sites/virtualNetworkConnections -PropertyObject $props -ApiVersion "2015-08-01" -force 

如果需要,可以通过修改routes属性来配置自定义路由。让我知道你是如何进行的,如果它解决了这种情况,请将这篇文章标记为答案。

马库斯

答案 1 :(得分:1)

我遇到了同样的问题,找不到使用PS模块执行此操作的方法。但是,现在已将功能添加到了Azure CLI。因此,您只需从脚本中调用它即可。

az webapp vnet-integration add -g "resource group name" -n "app service name" --vnet "vnet name" --subnet "subnet name"

答案 2 :(得分:0)

目前不支持此功能,我们将其列入待办事项列表,遗憾的是我现在还没有eta

相关问题