读取存储帐户的防火墙 IP 列表

Reading the firewall IP list for a storage account

是否可以使用 c# 代码读取 azure 中存储帐户允许的 IP 范围列表,即存储帐户 api

Is it possible to read the list of allowed IP range of an storage account in azure using c# code i.e storage account api.

是的,我们可以使用 Azure Fluent SDK to do that. About how to get auth file, please refer to another

using Microsoft.Azure.Management.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent;
using Microsoft.Azure.Management.ResourceManager.Fluent.Core;


var credentials = SdkContext.AzureCredentialsFactory.FromFile(@"auth file path");
var azure = Azure
            .Configure()
            .WithLogLevel(HttpLoggingDelegatingHandler.Level.Basic)
            .Authenticate(credentials)
            .WithDefaultSubscription();
var account = azure.StorageAccounts.GetByResourceGroup(resoureGroup, accountName);
var ipRange = account.IPAddressRangesWithAccess;

测试结果: