我正在使用 Azure CLI 并使用工作流定义来创建和运行逻辑应用工作流。逻辑应用的期望行为是每当将新文件上传到 Dropbox 的根目录时就将文件的副本存储在 Azure Blob 中。具有工作流程的逻辑应用程序确实已创建;我通过检查 Azure 门户确认了这一点。但是,工作流程无法正常运行,因为每当将新文件上传到保管箱时,该文件的副本都不会保存在 Azure Blob 中。
workflow.json:
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Create_blob_(V2)": {
"inputs": {
"body": "@triggerBody()",
"headers": {
"ReadFileMetadataFromServer": true
},
"host": {
"connection": {
"name": "RESOURCE_GROUP",
"connectionString": "DefaultEndpointsProtocol=https;AccountName=RESOURCE_GROUP;AccountKey=SOME_ACCOUNT_KEY;EndpointSuffix=core.windows.net"
}
},
"method": "post",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('RESOURCE_GROUP'))}/files",
"queries": {
"folderPath": "/SOME_FOLDER",
"name": "@base64ToString(triggerOutputs()['x-ms-file-name-encoded'])",
"queryParametersSingleEncoded": true
}
},
"runAfter": {},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"triggers": {
"When_a_file_is_created": {
"inputs": {
"authentication": {
"type": "Raw",
"scheme": "Bearer",
"parameter": "MY_ACCESS_TOKEN"
},
"method": "get",
"path": "/datasets/default/triggers/onnewfile",
"queries": {
"folderId": "6e202211-2856-4d17-9ded-5beb8b8626b0",
"inferContentType": true,
"queryParametersSingleEncoded": true
}
},
"metadata": {
"6e202211-2856-4d17-9ded-5beb8b8626b0": "/"
},
"recurrence": {
"frequency": "Minute",
"interval": 1
},
"type": "ApiConnection"
}
}
},
"kind": "Stateless"
}
在终端:
az logic workflow create --resource-group "intern-rg-dev" --name "dbx-trigger" --definition "workflow.json"
我已在终端中运行命令来创建具有给定工作流定义的逻辑应用程序,但不幸的是,它不起作用,而且我无法找出原因。我已经阅读了文档,但没有多大帮助。
使用 Azure CLI 和工作流定义的 Azure 逻辑应用程序不起作用:-
使用下面修改后的工作流定义代码来实现您的要求。
{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Get_file_content": {
"inputs": {
"host": {
"connection": {
"name": "xxxx",
"connectionString": "DefaultEndpointsProtocol=https;AccountName=RESOURCE_GROUP;AccountKey=SOME_ACCOUNT_KEY;EndpointSuffix=core.windows.net"
}
},
"method": "get",
"path": "/datasets/default/files/@{encodeURIComponent('/' & triggerBody()?['path'])}/content",
"queries": {
"inferContentType": true
}
},
"runAfter": {},
"type": "ApiConnection"
},
"Create_blob": {
"inputs": {
"body": "@outputs('Get_file_content')",
"headers": {
"x-ms-blob-type": "BlockBlob"
},
"host": {
"connection": {
"name": "xxxx"
}
},
"method": "put",
"path": "/v2/datasets/@{encodeURIComponent(encodeURIComponent('default'))}/files/@{encodeURIComponent('CONTAINER_NAME/' & triggerBody()?['name'])}",
"queries": {
"queryParametersSingleEncoded": true
}
},
"runAfter": {
"Get_file_content": [
"Succeeded"
]
},
"type": "ApiConnection"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"triggers": {
"When_a_file_is_created": {
"inputs": {
"authentication": {
"type": "Raw",
"scheme": "Bearer",
"parameter": "ACCESS_TOKEN"
},
"method": "get",
"path": "/datasets/default/triggers/onnewfile",
"queries": {
"folderId": "root", //Modify it as per your requirement
"inferContentType": true,
"queryParametersSingleEncoded": true
}
},
"metadata": {
"root": "/"
},
"recurrence": {
"frequency": "Minute",
"interval": 1
},
"type": "ApiConnection"
}
}
},
"kind": "Stateless"
}
完整命令:
az logic workflow create --resource-group "xxxx" --name "dbx-trigger" --definition "workflow.json"
输出: