列出与虚拟网络集成的 Azure 资源
List Azure resources integrated with a Virtual Network
我已经在 Azure 中设置了一个具有多个子网的虚拟网络 (VNet)。我还在该 VNet 的多个应用服务中使用 VNet 集成。应用服务 运行 在不同的应用服务计划中。
是否有办法列出在此 VNet 上使用 VNet 集成的所有应用服务(可能还有其他 Azure 资源)?我知道我可以在每个应用服务的网络设置中查看 VNet 集成,但是当有数百个应用服务需要查看时,这种方法太麻烦了。
这是一个脚本,用于列出订阅中启用了 VNet 集成的所有应用服务和功能应用。参考资料来自 this blog.
$AppServices = @(
az webapp list | ConvertFrom-Json
az functionapp list | ConvertFrom-Json
)
$VNetAppServices = foreach ($App in $AppServices) {
$Apps = az webapp vnet-integration list --n $App.Name -g $App.ResourceGroup
if ($Apps -ne "[]") {
$ServerFarm = $App.appServicePlanId -split '/'
$VNetIntData = $Apps | ConvertFrom-Json
$VNet = $VNetIntData.VnetResourceID -split '/'
[PSCustomObject]@{
AppServiceName = $App.Name
ServerFarm = $ServerFarm[8]
ResourceGroup = $App.ResourceGroup
Location = $App.Location
VNetName = $VNet[8]
SubnetName = $VNetIntData.name
VNetRG = $VNet[4]
}
}
}
$VNetAppServices | ft
我已经在 Azure 中设置了一个具有多个子网的虚拟网络 (VNet)。我还在该 VNet 的多个应用服务中使用 VNet 集成。应用服务 运行 在不同的应用服务计划中。
是否有办法列出在此 VNet 上使用 VNet 集成的所有应用服务(可能还有其他 Azure 资源)?我知道我可以在每个应用服务的网络设置中查看 VNet 集成,但是当有数百个应用服务需要查看时,这种方法太麻烦了。
这是一个脚本,用于列出订阅中启用了 VNet 集成的所有应用服务和功能应用。参考资料来自 this blog.
$AppServices = @(
az webapp list | ConvertFrom-Json
az functionapp list | ConvertFrom-Json
)
$VNetAppServices = foreach ($App in $AppServices) {
$Apps = az webapp vnet-integration list --n $App.Name -g $App.ResourceGroup
if ($Apps -ne "[]") {
$ServerFarm = $App.appServicePlanId -split '/'
$VNetIntData = $Apps | ConvertFrom-Json
$VNet = $VNetIntData.VnetResourceID -split '/'
[PSCustomObject]@{
AppServiceName = $App.Name
ServerFarm = $ServerFarm[8]
ResourceGroup = $App.ResourceGroup
Location = $App.Location
VNetName = $VNet[8]
SubnetName = $VNetIntData.name
VNetRG = $VNet[4]
}
}
}
$VNetAppServices | ft