如何为队列名称指定参数值以将消息发送到服务总线

How to specify a parameter value for the queue name for sending a msg to service bus

我的逻辑应用程序中有以下 "hard coded value" 代码,用于向服务总线发送消息

                  "actions": {
                    "Send_Message_To_Service_Bus": {
                      "type": "ApiConnection",
                      "inputs": {
                        "host": {
                          "connection": {
                            "name": "@parameters('$connections')['servicebus_1']['connectionId']"
                          }
                        },
                        "method": "post",
                        "path": "/@{encodeURIComponent('MyQueueOneHardCodedName')}/messages",
                        "body": {
                          "ContentData": "@{base64(item())}",
                          "SessionId": "@items('For_Each_Item_Loop')?['MetaData']?['MetaDataUuid']"
                        },
                        "queries": {
                          "systemProperties": "None"
                        }
                      },
                      "runAfter": {}
                    }
                  },

运算值为

MyQueueOneHardCodedName

我想用变量替换它

我有正确的参数设置,下面显示了 ServiceBusQueueNameLogicAppParameter 的部分代码

      "parameters": {
        "$connections": {
          "defaultValue": {},
          "type": "Object"
        },
        "ServiceBusQueueNameLogicAppParameter": {
          "type": "string"
        }
      },

我试过了

"path": "/@{encodeURIComponent('@{parameters('ServiceBusQueueNameLogicAppParameter')}')}/messages",

 "path": "/@{encodeURIComponent(@{parameters('ServiceBusQueueNameLogicAppParameter')})}/messages",

 "path": "/@{encodeURIComponent('@parameters('ServiceBusQueueNameLogicAppParameter')')}/messages",

"path": "/@{encodeURIComponent(@parameters('ServiceBusQueueNameLogicAppParameter'))}/messages",

大多数错误反映了这一点:

is not valid: the string character '@' at position '19' is not expected

试试这个:

"path": "/@{encodeURIComponent(parameters('ServiceBusQueueNameLogicAppParameter'))}/messages"

嵌套 工作流表达式不需要额外的 @ 符号。

HTH