我使用 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
uj5u.com熱心網友回復:
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)
在輸入/輸出中閱讀更多內容,應用。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/475446.html
