Microsoft.Solutions.ArmApiControl UI elementMicrosoft.Solutions.ArmApiControl UI element

ArmApiControl 可让你从 Azure 资源管理器 API 操作获取结果。ArmApiControl lets you get results from an Azure Resource Manager API operation. 使用结果填充其他控件中的动态内容。Use the results to populate dynamic content in other controls.

UI 示例UI sample

此控件没有 UI。There's no UI for this control.

架构Schema

下面的示例显示了此控件的架构:The following example shows the schema for this control:

{
    "name": "testApi",
    "type": "Microsoft.Solutions.ArmApiControl",
    "request": {
        "method": "{HTTP-method}",
        "path": "{path-for-the-URL}",
        "body": {
            "key1": "val1",
            "key2": "val2"
        }
    }
}

示例输出Sample output

控件的输出不会显示给用户。The control's output is not displayed to the user. 相反,操作的结果将用于其他控件。Instead, the result of the operation is used in other controls.

备注Remarks

  • request.method 属性指定 HTTP 方法。The request.method property specifies the HTTP method. 仅允许 GETPOSTOnly GET or POST are allowed.

  • request.path 属性指定一个 URL,该 URL 必须是指向 ARM 终结点的相对路径。The request.path property specifies a URL that must be a relative path to an ARM endpoint. 它可以是静态路径,也可以通过引用其他控件的输出值来动态构造。It can be a static path or can be constructed dynamically by referring output values of the other controls.

    例如,对 Microsoft.Network/expressRouteCircuits 资源提供程序的 ARM 调用:For example, an ARM call into Microsoft.Network/expressRouteCircuits resource provider:

    "path": "<subid>/resourceGroup/<resourceGroupName>/providers/Microsoft.Network/expressRouteCircuits/<routecircuitName>/?api-version=2020-05-01"
    
  • request.body 属性为可选。The request.body property is optional. 使用它指定与请求一起发送的 JSON 正文。Use it to specify a JSON body that is sent with the request. 正文可以是静态内容,也可以通过引用其他控件的输出值来动态构造。The body can be static content or constructed dynamically by referring to output values from other controls.

示例Example

在下面的示例中,providersApi 元素调用一个 API 来获取提供程序对象的数组。In the following example, the providersApi element calls an API to get an array of provider objects.

providersDropDown 元素的 allowedValues 属性配置为获取提供程序的名称。The allowedValues property of the providersDropDown element is configured to get the names of the providers. 它将显示在下拉列表中。It displays them in the dropdown list.

{
    "name": "providersApi",
    "type": "Microsoft.Solutions.ArmApiControl",
    "request": {
        "method": "GET",
        "path": "[concat(subscription().id, '/providers/Microsoft.Network/expressRouteServiceProviders?api-version=2019-02-01')]"
    }
},
{
    "name": "providerDropDown",
    "type": "Microsoft.Common.DropDown",
    "label": "Provider",
    "toolTip": "The provider that offers the express route connection.",
    "constraints": {
        "allowedValues": "[map(steps('settings').providersApi.value, (item) => parse(concat('{\"label\":\"', item.name, '\",\"value\":\"', item.name, '\"}')))]",
        "required": true
    },
    "visible": true
}

有关使用 ArmApiControl 检查资源名称可用性的示例,请参阅 Microsoft.Common.TextBoxFor an example of using the ArmApiControl to check the availability of a resource name, see Microsoft.Common.TextBox.

后续步骤Next steps