从 Azure 托管应用程序调用 Azure 自定义提供程序操作

Invoke an Azure Custom Provider Action from an Azure Managed App

我正在尝试从“Hello World”概念验证托管应用程序中的托管应用程序调用自定义提供程序。我尝试使用以下 Microsoft document,但是函数应用程序似乎不起作用,并且在部署时在 Azure 中部署失败,所以我尝试自己制作。

我的资源提供者是在我的托管应用程序部署的 mainTemplate.json 中定义的,部署后我可以从 REST GET 请求中检索以下定义。当我从 Azure CLI 调用资源提供程序时,我得到了所引用函数应用程序的响应,正如我所期望的那样。

{
    "properties": {
        "actions": [
            {
                "name": "public/product/GetDocumentation",
                "routingType": "Proxy",
                "endpoint": "https://faraveXXXX.azurewebsites.net/api/{requestPath}"
            }
        ],
        "provisioningState": "Succeeded"
    },
    "id": "/subscriptions/XXXXXXXX-995e-4e82-a86e-499522a63304/resourceGroups/mrg-Rob-20210311141704/providers/Microsoft.CustomProviders/resourceproviders/public",
    "name": "public",
    "type": "Microsoft.CustomProviders/resourceproviders",
    "location": "eastus",
    "tags": {}
}

我在 viewDefinition.json 中创建了两个按钮。这是整个文件。

{
    "$schema": "https://schema.management.azure.com/schemas/viewdefinition/0.0.1-preview/ViewDefinition.json#",
    "contentVersion": "0.0.0.1",
    "views": [
        {
            "kind": "Overview",
            "properties": {
                "header": "TitleHeader",
                "description": "TitleHeaderDescription",
                "commands": [
                    {
                        "displayName": "Click",
                        "path": "public/product/GetDocumentation",
                        "icon": "Check"
                    }
                ]
            }
        },
        {
            "kind": "Metrics",
            "properties": {
                "displayName": "This is my metrics view",
                "version": "1.0.0",
                "charts": [
                    {
                        "displayName": "Sample chart",
                        "chartType": "Bar",
                        "metrics": [
                            {
                                "name": "Availability",
                                "aggregationType": "avg",
                                "resourceTagFilter": [ "tag1" ],
                                "resourceType": "Microsoft.Storage/storageAccounts",
                                "namespace": "Microsoft.Storage/storageAccounts"
                            }
                        ]
                    }
                ]
            }
        },
        {
            "kind": "CustomResources",
            "properties": {
                "displayName": "Test custom resource type",
                "version": "1.0.0",
                "resourceType": "public",
                "createUIDefinition": { },
                "commands": [
                    {
                        "displayName": "Custom Context Action",
                        "path": "public/product/GetDocumentation",
                        "icon": "Stop",
                        "createUIDefinition": { }
                    }
                ],
                "columns": [
                    {"key": "name", "displayName": "Name"},
                    {"key": "properties.myProperty1", "displayName": "Property 1"},
                    {"key": "properties.myProperty2", "displayName": "Property 2", "optional": true}
                ]
            }
        },
        {
            "kind": "Associations",
            "properties": {
                "displayName": "Test association resource type",
                "version": "1.0.0",
                "targetResourceType": "Microsoft.Compute/virtualMachines",
                "createUIDefinition": { }
            }
        }
    ]
}

当我部署托管应用程序并单击概览页面上的按钮时,出现以下错误。

Failed running command 'Click' in 'managedAppTest'. Error: The resource provider 'public' did not find a valid route definition for 'public/product/GetDocumentation'. Please ensure the route exists and is correctly configured.

当您从托管应用程序调用时,路径需要以“自定义”字面量为前缀,您不需要指定“public”自定义提供程序 name.For这种情况意味着您需要将路径更新为如下内容:

"路径": "customproduct/GetDocumentation",