如何在pulumi python代码中传递连接参数

问题描述

我正在尝试将我的逻辑应用程序 ARM 模板转换为 pulumi 。但它不接受我的 JSON 形式的连接参数。我需要在逻辑应用步骤中传递我的 github 连接详细信息

你能告诉我如何在 pulumi python 中做到这一点吗?

"parameters": {
        "$connections": {
            "value": {
                "github": {
                    "connectionId": "/subscriptions/b417b96c-ff1e-4d07-bc32-74bd70a2a033/resourceGroups/task/providers/Microsoft.Web/connections/github","connectionName": "github","id": "/subscriptions/b417b96c-ff1e-4d07-bc32-74bd70a2a033/providers/Microsoft.Web/locations/eastus/managedApis/github"
                }
            }
        }

我的代码

example_action_custom = azure.logicapps.ActionCustom("exampleActionCustom",logic_app_id=example_workflow.id,name= "Create_a_repository_using_a_template",body="""{
    "inputs": {
        "body": {
            "name": "cog-chalnge-pmi-shah-@{triggerBody()?['ghusername']}","owner": "@triggerBody()?['ghusername']","private": true    
        },"headers": {
            "Accept": "application/vnd.github.baptiste-preview+json"
        },"host": {
            "connection": {
                "name": "@parameters('$connections')['github']['connectionId']"
            }
        },"method": "post","parameters": {
            "$connections": {
                "value": {
                    "github": {
                        "connectionId": "/subscriptions/b417b96c-ff1e-4d07-bc32-74bd70a2a033/resourceGroups/bluecode_test_task/providers/Microsoft.Web/connections/github","id": "/subscriptions/b417b96c-ff1e-4d07-bc32-74bd70a2a033/providers/Microsoft.Web/locations/eastus/managedApis/github"
                    }
                }
            }
        },"path": "/repos/@{encodeURIComponent('')}/@{encodeURIComponent('')}/generate"
    },"runAfter": {},"type": "ApiConnection"
}
""")

enter image description here

无法创建github连接器

我尝试过的有用链接 - https://www.pulumi.com/docs/reference/pkg/azure/logicapps/workflow/ https://www.pulumi.com/docs/reference/pkg/azure/logicapps/actioncustom

解决方法

azure.logicapps.ActionCustom 不能传递参数。我使用了另一个类来传递工作流 azure_native.logic.Workflow。

https://www.pulumi.com/docs/reference/pkg/azure-native/logic/workflow/