azure - 如何在 Pulumi 上使用 "GetComponnectOutput"访问 Azure App Insights 输出

标签 azure azure-application-insights pulumi appinsights pulumi-python

我使用 Pulumi 创建了一个 Azure App Insights,并使用 GetComponnectOutput 我收到了如下输出:

示例代码:

app_insights_key = insights.get_component_output(
    resource_group_name=temp_resources_group.name,
    resource_name=temp_app_insights.name,
)

pulumi.export('the output is:', app_insights_key)

输出是:

Outputs:
  + the output is:: {
      + app_id                             : "46470d16-bff3--b6fa8effc890"
      + application_id                     : "app-insights-temp112-gx"
      + application_type                   : "web"
      + connection_string                  : "InstrumentationKey=8418a8ce.com/"
      + creation_date                      : "2022-05-14T17:40:20.5340124+00:00"
      + disable_ip_masking                 : true
      + etag                               : "\"e800edf3-0000-0100-0000-627fe9860000\""
      + flow_type                          : "Bluefield"
      + id                                 : "/subscriptions/7bb4482f-3343-4b08"
      + ingestion_mode                     : "LogAnalytics"
      + instrumentation_key                : "8418a8cd-5700-7-3138752bd5f6"

我想访问instrumentation_key并尝试使用以下方式:

app_key = app_insights_key["instrumentation_key"]

但是我收到一个错误。

 RuntimeError: Event loop is closed

最佳答案

get_component_output返回类型为Output[GetComponentResult],因此需要使用apply来获取其属性:

component = insights.get_component_output(
    resource_group_name="temp_resources_group.name",
    resource_name="temp_app_insights.name",
)

app_insights_key = component.apply(lambda c: c.instrumentation_key)

了解更多信息Inputs/Outputs, Apply .

关于azure - 如何在 Pulumi 上使用 "GetComponnectOutput"访问 Azure App Insights 输出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72246559/

相关文章:

iframe - Windows Azure iframe 域提供商 = X-Frame-Options 问题

azure-application-insights - 如果<某事>,则在 Kusto 中不执行任何操作

azure - 在 Windows 应用商店应用程序中启动后如何停止收集遥测数据?

c# - 我们可以使用应用程序洞察来进行集中日志记录吗?

docker - Pulumi - 如何从私有(private)注册表中提取 docker 镜像?

azure - 与使用 Azure .NET SDK 相比,Pulumi 有那么神奇吗?

c# - 作为 serviceprinciple 运行时,Pulumi 无法访问刚刚创建的 keyvault

azure - Azure 上带有负载均衡器的 SignalR 连接

azure - 如何从计算机上的 VM 名称获取 Azure 规模集名称

azure - 存储客户端 v7 使用的 Azure 存储 REST API 版本 "2015-07-08"是否在任何地方都有记录?