简体   繁体   English

从 azure 查询 azure 应用程序网关设置或整个 ARM 模板

[英]Query azure application gateway settings or whole ARM template from azure

Hello I want to build back end c# where i will able to query all settings of the azure application gateway i have already configured.您好,我想构建后端 c#,我将能够在其中查询我已经配置的 azure 应用程序网关的所有设置。 I have tried with Frontdoor and used Frontdoorclient to connect to frontdoor and able to query all loadbalancer settings and other settings.我尝试过使用 Frontdoor 并使用 Frontdoorclient 连接到前门并能够查询所有负载均衡器设置和其他设置。 That helped me because front door on Azure.management.Fluent.Frontdoor.dlll has client and for azure.mamgement.network.dll i cant find client for azure application gateway. That helped me because front door on Azure.management.Fluent.Frontdoor.dlll has client and for azure.mamgement.network.dll i cant find client for azure application gateway.

Azure SDK does not provide a management client to directly manage Azure application gateway. Azure SDK没有提供管理客户端直接管理Azure应用网关。 If we want to manage it, we should use NetworkManagementClient.ApplicationGateways to manage it.如果我们想管理它,我们应该使用NetworkManagementClient.ApplicationGateways来管理它。 For more details, please refer to the document更多详细信息,请参阅文档

  1. Create a service principal and assign a role to sp创建服务主体并将角色分配给 sp
az login
az account set --subscription "<your subscription id>"
# the sp will have Azure Contributor role
az ad sp create-for-rbac -n "readMetric" 

在此处输入图像描述

  1. Code代码
# use msal get token
var app = ConfidentialClientApplicationBuilder.Create(<sp app id>)
           .WithAuthority(AzureCloudInstance.AzurePublic, "<sp tenantID>")
           .WithClientSecret(<sp password>)
           .Build();
string[] scopes = new string[] { "https://management.azure.com/.default" };
var  result = await app.AcquireTokenForClient(scopes)
                   .ExecuteAsync();
TokenCredentials tokenCredentials = new TokenCredentials(result.AccessToken,"Bearer");

 NetworkManagementClient networkManagementClient = new NetworkManagementClient(tokenCredentials);
ApplicationGateway appgateway =await networkManagementClient.ApplicationGateways.GetAsync("<groupName>", "<resourceName>");

// get application gateway settings:https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.management.network.models.applicationgateway?view=azure-dotnet


声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 简单的 ARM 模板在 Azure Cli 中不起作用 - Simple ARM template not working in Azure Cli .Net 6 函数应用程序未从 Azure 应用程序设置中获取值 - .Net 6 function app not getting values from Azure application settings 使 azure function 在发布到 azure 门户而不是应用程序设置后从 Azure 密钥保管库读取连接字符串 - Make azure function to read the connection string from Azure key vault after published into azure portal not from application settings Azure应用程序网关斜杠重写错误 - Azure Application Gateway Slash Rewrite Error 从 Azure Function 读取设置 - Reading settings from a Azure Function 从ARM模板部署新的Azure VM时,无法格式化有效的JObject for.WithParameters() - Trouble formatting valid JObject for .WithParameters() when deploying new Azure VM from ARM Template 无法在Azure功能中读取应用程序设置 - Trouble reading Application Settings in Azure Function ASP.NET Web应用程序Azure设置 - ASP.NET Web Application Azure Settings 覆盖 azure app 服务应用程序设置中的数组 - Override an array in azure app service application settings Azure功能如何将应用程序设置添加到绑定 - Azure Functions how to add application settings to bindings
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM