【问题标题】:Invoke an Azure Custom Provider Action from an Azure Managed App从 Azure 托管应用调用 Azure 自定义提供程序操作
【发布时间】:2021-03-11 21:23:11
【问题描述】:

我正在尝试从“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": { }
            }
        }
    ]
}

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

在“managedAppTest”中运行命令“Click”失败。错误:资源 提供者“公共”没有找到有效的路由定义 “公共/产品/GetDocumentation”。 请确保路由存在且配置正确。

【问题讨论】:

    标签: azure azure-managed-app azure-custom-providers


    【解决方案1】:

    当您从托管应用程序调用时,路径需要以“自定义”文字为前缀,并且您不需要指定“公共”自定义提供程序名称。对于您的情况,这意味着您需要更新这样的路径:

    "path": "customproduct/GetDocumentation",

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-01-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-29
    • 2021-10-08
    相关资源
    最近更新 更多