从服务计划中获取 vnet 集成信息

时间:2020-12-23 17:31:38

标签: azure powershell azure-functions

上下文

使用如下代码部署具有 vnet 集成的 Azure 函数:

$properties = @{
            subnetResourceId = $subnet.Id
        }

$vNetParams = @{
                ResourceName      = "$webapp/VirtualNetwork"
                Location          = $Location
                ResourceGroupName = $ResourceGroupName
                ResourceType      = "Microsoft.Web/sites/networkConfig"
                PropertyObject    = $properties
}

$result = New-AzResource @vNetParams -Force
                           

这很好用。

该项目通过在辐条 VNET 中查找可用子网来获取 $subnet。 所以我不想在 VNET 集成已经存在的情况下运行之前的代码。

我需要什么

了解函数是否已集成 VNET 的方法

我测试了什么

Get-AzFunctionApp  -ResourceGroupName $ResourceGroupName -Name $webapp 

Get-AzFunctionAppPlan -ResourceGroupName $ResourceGroupName -Name $servicePlan 

Get-AzAppServicePlan -ResourceGroupName $ResourceGroupName -Name $servicePlan 

不返回任何 vnet 信息

Get-AzResource doesn't work with this resource: "$webapp/VirtualNetwork"  (not found)

2 个答案:

答案 0 :(得分:0)

要检查函数应用是否已经集成了 vnet,只需使用以下命令。

$VnetName = (Get-AzFunctionApp -ResourceGroupName <groupname> -Name <functionappname>).SiteConfig.VnetName
if($VnetName){
    Write-Output "already intergration"
}

enter image description here

答案 1 :(得分:0)

在门户中有一种方法可以解决这个问题。

  1. 导航到 Azure 门户
  2. 选择相应的 Web App 或 Function App
  3. 导航到“诊断和解决问题”并搜索“VNet 集成信息”
  4. 这将加载一个刀片,其中包含该应用服务计划中 Web 应用的详细信息

这就是用户界面的样子 VNet Integration Information