azure ARM模板:LogicApp连接出现找不到API错误

mmvthczy  于 2023-02-19  发布在  其他
关注(0)|答案(1)|浏览(103)

我正在尝试设置一个LogicApp,该LogicApp已设置了与CosmosDB的连接。CosmosDB资源已设置,但连接失败。
错误:
{"状态":"失败","错误":{"代码":" ApiNotFound ","消息":"找不到API" cosmsdb "。"}}
我的ARM模板:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "databaseAccounts_wkshp_cosmos_name": {
      "defaultValue": "mycosmosdb",
      "type": "String"
    },
    "backendLogicApp": {
      "defaultValue": "t12msds5lg",
      "type": "String"
    },
    "location": {
      "defaultValue": "westus2",
      "type": "String"
    },
    "cosmosConnection": {
      "defaultValue": "cosmos",
      "type": "String"
    }
  },
  "resources": [
    {
      "type": "Microsoft.Logic/workflows",
      "apiVersion": "2019-05-01",
      "name": "[parameters('backendLogicApp')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[resourceId('Microsoft.Web/connections', parameters('cosmosConnection'))]"
      ],
      "properties": {
        "state": "Enabled",
        "definition": {
          "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
          "contentVersion": "1.0.0.0",
          "parameters": {
            "$connections": {
              "defaultValue": {},
              "type": "Object"
            }
          },
          "triggers": {},
          "actions": {},
          "outputs": {}
        },
        "parameters": {
          "$connections": {
            "value": {
              "cosmosdb": {
                "connectionId": "[resourceId('Microsoft.Web/connections', parameters('databaseAccounts_wkshp_cosmos_name'))]",
                "connectionName": "cosmosdb",
                "id": "[subscriptionResourceId('Microsoft.Web/locations/managedApis', parameters('location'), 'cosmosdb')]"
              }
            }
          }
        }
      }
    },
    {
      "type": "Microsoft.DocumentDB/databaseAccounts",
      "apiVersion": "2022-08-15",
      "name": "[parameters('databaseAccounts_wkshp_cosmos_name')]",
      "location": "[parameters('location')]",
      "tags": {
        "defaultExperience": "Core (SQL)",
        "hidden-cosmos-mmspecial": ""
      },
      "kind": "GlobalDocumentDB",
      "identity": {
        "type": "None"
      },
      "properties": {
        "publicNetworkAccess": "Enabled",
        "enableAutomaticFailover": false,
        "enableMultipleWriteLocations": false,
        "isVirtualNetworkFilterEnabled": false,
        "virtualNetworkRules": [],
        "disableKeyBasedMetadataWriteAccess": false,
        "enableFreeTier": false,
        "enableAnalyticalStorage": true,
        "analyticalStorageConfiguration": {
          "schemaType": "WellDefined"
        },
        "databaseAccountOfferType": "Standard",
        "defaultIdentity": "FirstPartyIdentity",
        "networkAclBypass": "None",
        "disableLocalAuth": false,
        "enablePartitionMerge": false,
        "consistencyPolicy": {
          "defaultConsistencyLevel": "Session",
          "maxIntervalInSeconds": 5,
          "maxStalenessPrefix": 100
        },
        "locations": [
          {
            "locationName": "West US",
            "provisioningState": "Succeeded",
            "failoverPriority": 0,
            "isZoneRedundant": false
          }
        ],
        "cors": [],
        "capabilities": [
          {
            "name": "EnableServerless"
          }
        ],
        "ipRules": [],
        "backupPolicy": {
          "type": "Periodic",
          "periodicModeProperties": {
            "backupIntervalInMinutes": 240,
            "backupRetentionIntervalInHours": 8,
            "backupStorageRedundancy": "Geo"
          }
        },
        "networkAclBypassResourceIds": [],
        "keysMetadata": {}
      }
    },
    {
      "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases",
      "apiVersion": "2022-08-15",
      "name": "[concat(parameters('databaseAccounts_wkshp_cosmos_name'), '/SQLDatabase')]",
      "dependsOn": [
        "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccounts_wkshp_cosmos_name'))]"
      ],
      "properties": {
        "resource": {
          "id": "SQLDatabase"
        }
      }
    },
    {
      "type": "Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions",
      "apiVersion": "2022-08-15",
      "name": "[concat(parameters('databaseAccounts_wkshp_cosmos_name'), '/00000000-0000-0000-0000-000000000001')]",
      "dependsOn": [
        "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccounts_wkshp_cosmos_name'))]"
      ],
      "properties": {
        "roleName": "Cosmos DB Built-in Data Reader",
        "type": "BuiltInRole",
        "assignableScopes": [
          "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccounts_wkshp_cosmos_name'))]"
        ],
        "permissions": [
          {
            "dataActions": [
              "Microsoft.DocumentDB/databaseAccounts/readMetadata",
              "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/executeQuery",
              "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/readChangeFeed",
              "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/read"
            ],
            "notDataActions": []
          }
        ]
      }
    },
    {
      "type": "Microsoft.DocumentDB/databaseAccounts/sqlRoleDefinitions",
      "apiVersion": "2022-08-15",
      "name": "[concat(parameters('databaseAccounts_wkshp_cosmos_name'), '/00000000-0000-0000-0000-000000000002')]",
      "dependsOn": [
        "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccounts_wkshp_cosmos_name'))]"
      ],
      "properties": {
        "roleName": "Cosmos DB Built-in Data Contributor",
        "type": "BuiltInRole",
        "assignableScopes": [
          "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccounts_wkshp_cosmos_name'))]"
        ],
        "permissions": [
          {
            "dataActions": [
              "Microsoft.DocumentDB/databaseAccounts/readMetadata",
              "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/*",
              "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers/items/*"
            ],
            "notDataActions": []
          }
        ]
      }
    },
    {
      "type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers",
      "apiVersion": "2022-08-15",
      "name": "[concat(parameters('databaseAccounts_wkshp_cosmos_name'), '/SQLDatabase/transactionDb')]",
      "dependsOn": [
        "[resourceId('Microsoft.DocumentDB/databaseAccounts/sqlDatabases', parameters('databaseAccounts_wkshp_cosmos_name'), 'SQLDatabase')]",
        "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccounts_wkshp_cosmos_name'))]"
      ],
      "properties": {
        "resource": {
          "id": "transactionDb",
          "indexingPolicy": {
            "indexingMode": "consistent",
            "automatic": true,
            "includedPaths": [
              {
                "path": "/*"
              }
            ],
            "excludedPaths": [
              {
                "path": "/\"_etag\"/?"
              }
            ]
          },
          "partitionKey": {
            "paths": [
              "/id"
            ],
            "kind": "Hash",
            "version": 2
          },
          "uniqueKeyPolicy": {
            "uniqueKeys": []
          },
          "conflictResolutionPolicy": {
            "mode": "LastWriterWins",
            "conflictResolutionPath": "/_ts"
          },
          "analyticalStorageTtl": -1
        }
      }
    },
    {
      "type": "Microsoft.Web/connections",
      "apiVersion": "2016-06-01",
      "name": "[parameters('cosmosConnection')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccounts_wkshp_cosmos_name'))]"
      ],
      "properties": {
        "displayName": "Router",
        "api": {
          "id": "[subscriptionResourceId('Microsoft.Web/locations/managedApis', parameters('location'), 'cosmosdb')]"
        },
        "parameterValues": {
          "connectionString": "[listConnectionStrings(resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('databaseAccounts_wkshp_cosmos_name')), '2019-12-12').connectionStrings[0].connectionString]"
        }
      }
    }
  ]
}
xqk2d5yq

xqk2d5yq1#

尝试使用以下格式进行cosmos数据库连接,

"parameters": {
"$connections": {
"value": {
"documentdb": {
"connectionId": "[parameters('connections_documentdb_externalid')]",
"connectionName": "documentdb",
"id": "/subscriptions/xxxxx/providers/Microsoft.Web/locations/centralus/managedApis/documentdb"
}
}
}
}
  • 我已经创建了一个示例逻辑应用程序,它将从cosmos数据库中检索文档,逻辑应用程序的设计者是

  • 从逻辑应用程序导出模板,并下载带参数的模板文件。Template.json文件:

{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "workflows_cosmoslapp_name": {
            "defaultValue": "cosmoslapp",
            "type": "String"
        },
        "connections_documentdb_externalid": {
            "defaultValue": "/subscriptions/xxxxx/resourceGroups/so1/providers/Microsoft.Web/connections/documentdb",
            "type": "String"
        }
    },
    "variables": {},
    "resources": [
        {
            "type": "Microsoft.Logic/workflows",
            "apiVersion": "2017-07-01",
            "name": "[parameters('workflows_cosmoslapp_name')]",
            "location": "centralus",
            "properties": {
                "state": "Enabled",
                "definition": {
                    "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
                    "contentVersion": "1.0.0.0",
                    "parameters": {
                        "$connections": {
                            "defaultValue": {},
                            "type": "Object"
                        }
                    },
                    "triggers": {
                        "Recurrence": {
                            "recurrence": {
                                "frequency": "Minute",
                                "interval": 3
                            },
                            "evaluatedRecurrence": {
                                "frequency": "Minute",
                                "interval": 3
                            },
                            "type": "Recurrence"
                        }
                    },
                    "actions": {
                        "Get_all_documents_(V3)": {
                            "runAfter": {},
                            "type": "ApiConnection",
                            "inputs": {
                                "host": {
                                    "connection": {
                                        "name": "@parameters('$connections')['documentdb']['connectionId']"
                                    }
                                },
                                "method": "get",
                                "path": "/v2/cosmosdb/@{encodeURIComponent('AccountNameFromSettings')}/dbs/@{encodeURIComponent('testdb')}/colls/@{encodeURIComponent('cid')}/docs"
                            }
                        }
                    },
                    "outputs": {}
                },
                "parameters": {
                    "$connections": {
                        "value": {
                            "documentdb": {
                                "connectionId": "[parameters('connections_documentdb_externalid')]",
                                "connectionName": "documentdb",
                                "id": "/subscriptions/xxxx/providers/Microsoft.Web/locations/centralus/managedApis/documentdb"
                            }
                        }
                    }
                }
            }
        }
    ]
}
  • 使用自定义部署,部署此模板和另一个使用相同操作创建的逻辑应用程序,并连接到cosmos db。
  • 新逻辑应用程序

    的设计器

相关问题