在Azure Powershell中获取Webapp的受限IP [英] To get the restricted ips for webapp in Azure powershell

查看:44
本文介绍了在Azure Powershell中获取Webapp的受限IP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以使用Powershell cmdlet为Azure中的Web应用获取受限IP.

Is there any way to get the restricted ips for the webapps in Azure using powershell cmdlets.

推荐答案

此处是显示订阅中所有Azure WebApp IP限制的功能,供您参考.

Here is a function show all Azure WebApp IP restrictions in subscription for your reference.

function Get-WebAppIPRestrictions {

    if (!(Get-AzureRmContext)) {
        Write-Host "Please login to your Azure account"
        Login-AzureRmAccount
    }
    $APIVersion = ((Get-AzureRmResourceProvider -ProviderNamespace Microsoft.Web).ResourceTypes | Where-Object ResourceTypeName -eq sites).ApiVersions[0]
    $WebApps = Get-AzureRmWebApp
    foreach ($webApp in $WebApps) {

        $WebAppName = $WebApp.SiteName
        $WebAppRGName = $WEbApp.ResourceGroup
        $WebAppConfig = (Get-AzureRmResource -ResourceType Microsoft.Web/sites/config -ResourceName  $WebAppName -ResourceGroupName $WebAppRGName -ApiVersion $APIVersion)
        $IpSecurityRestrictions = $WebAppConfig.Properties.ipsecurityrestrictions
        if ($IpSecurityRestrictions -eq $null) {
            Write-Host "No IP restrictions found for WebApp $WebAppName ."

        }
        else {
            Write-Host "IP restrictions set for WebApp $WebAppName : "
            $IpSecurityRestrictions

        }
    }
}

这篇关于在Azure Powershell中获取Webapp的受限IP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆