c# - 如何使用 Fluent 资源管理器 SDK 获取部署的输出资源?

标签 c# azure azure-sdk-.net azure-sdk azure-fluent-api

使用 GET Deployments endpoint 时通过 Azure REST API,可以获取给定部署的详细信息,包括列出从 ARM 模板部署创建的实际资源的 outputResources

不幸的是,在使用 Azure 资源管理器 Fluent SDK 时,我似乎找不到访问 outputResources 的等效方法。

我尝试过使用以下内容:

var deployments = ResourceManager.Authenticate(credentials)
.WithSubscription(subscriptionId)
.Deployments.ListByResourceGroup(resourceGroup)
.Where(x => x.Name == deploymentName)
.OrderByDescending(x => x.Timestamp)
.First();

但这似乎不允许我获取已部署的实际资源的详细信息。

这些似乎是部署唯一可访问的属性 enter image description here

最佳答案

您可以使用Azure Management Libraries for .NET获取部署的详细信息。

  1. 安装 Microsoft.Azure.Management.Fluent 包

  2. 创建一个身份验证文件 AUTH.md

  3. 示例

    static void Main(string[] args)
    {
        IAzure azure = Azure.Authenticate("C:\\Users\\v-linjji\\my.azureauth").WithDefaultSubscription();
        var deployments = azure.Deployments.ListByResourceGroup("JackWebApp");
        foreach(var deployment in deployments)
        {
            Console.WriteLine(deployment.Timestamp + " -> " + deployment.Name);
    
            foreach(var dependency in deployment.Dependencies)
            {
                Console.WriteLine(dependency.Id);
            }
    
            foreach(var operation in deployment.DeploymentOperations.List())
            {
                Console.WriteLine(operation.OperationId + " -> " + operation.StatusCode);
            }
    
            Console.WriteLine("Outputs:" + deployment.Outputs);
    
            Console.WriteLine();
        }
    
        Console.ReadLine();
    }
    

结果:

enter image description here

关于c# - 如何使用 Fluent 资源管理器 SDK 获取部署的输出资源?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57185914/

相关文章:

node.js - Node 要监听azure ubuntu vm的端口/IP地址

sql-server - Azure SQL 数据库 - 在存储过程中获取文件内容的正确方法

c# - Azure资源管理器-获取资源组的所有资源

c# - 向 WCF 主机进程发送消息

c# - 如何使用 C#/WPF 为 MouseEnter 和 MouseLeave 事件上的 ListBox 项目设置动画?

database - 通过现有数据库还原 Azure SQL DB 以维护备份历史记录

visual-studio - 在 Visual Studio 中,使用 Windows Azure 存储, "Remember Account Key"保存在哪里?

azure - Azure.Messaging.ServiceBus 的 ServiceBusClient 类的 token 到期时间

c# - C# 中的数据绑定(bind)与 View 以及如何更新它们

c# - 用于生成属性和支持字段的代码生成器工具