How to set the connection string for a Service Bus Logic App action in an ARM template?

拟墨画扇 提交于 2019-12-11 10:46:51

问题


I'm attempting to deploy an Azure Logic App that includes an action to Send a message on a Service Bus using an ARM template.

In addition to deploying the Logic App, the ARM template deploys a Service Bus Namespace, a Queue and two AuthorizationRule (one for sending and one for listening).

I want to dynamically set the connection information for the Send Service Bus Message action to use the Connection string generated for the AuthorizationRule that supports sending.

When I create this in the portal editor (specifying the connection string for sending), I noticed the following is generated in code view...

"Send_message.": {
    "conditions": [
        {
            "dependsOn": "<previous action>"
        }
    ],
    "inputs": {
        "body": {
            "ContentData": "@{encodeBase64(triggerBody())}"
        },
        "host": {
            "api": {
                "runtimeUrl": "https://logic-apis-westus.azure-apim.net/apim/servicebus"
            },
            "connection": {
                "name": "@parameters('$connections')['servicebus']['connectionId']"
            }
        },
        "method": "post",
        "path": "/@{encodeURIComponent(string('<queuename>'))}/messages"
    },
    "type": "apiconnection"
}

},

I assume that the connection information is somehow buried in @parameters('$connections')['servicebus']['connectionId']"

I then used resources.azure.com to navigate to the logic app to see if I could get more details as to how @parameters('$connections')['servicebus']['connectionId']" is defined.

I found this:

"parameters": {
  "$connections": {
    "value": {
      "servicebus": {
        "connectionId": "/subscriptions/<subguid>/resourceGroups/<rgname>/providers/Microsoft.Web/connections/servicebus",
        "connectionName": "servicebus",
        "id": "/subscriptions/<subguid>/providers/Microsoft.Web/locations/westus/managedApis/servicebus"
      }
    }
  }
}

But I still don't see where the connection string is set.

Where can I set the connection string for the service bus action in an ARM template using something like the following?

[listkeys(variables('sendAuthRuleResourceId'), variables('sbVersion')).primaryConnectionString]

EDIT: Also, I've referred to was seems to be a promising Azure quick start on github (based on the title), but I can't make any sense of it. It appears to use an older schema 2014-12-01-preview, and the "queueconnector" references an Api Gateway. If there is a newer example out there for this scenario, I'd love to see it.


回答1:


As you know connections is a resource so it needs to be created first did you refer this https://blogs.msdn.microsoft.com/logicapps/2016/02/23/deploying-in-the-logic-apps-preview-refresh/. Quick start link you are referring is for older schema.




回答2:


I've recently worked on an ARM Template for the deployment of logic apps and service bus connection. Here is the sample template for configuring service bus connection string within the type "Microsoft.Web/connections". Hope it helps.

 {
    "type": "Microsoft.Web/connections",
    "apiVersion": "2016-06-01",
    "name": "[parameters('connections_servicebus_name')]",
    "location": "centralus",
    "dependsOn": [
      "[resourceId('Microsoft.ServiceBus/namespaces/AuthorizationRules', parameters('ServiceBusNamespace'), 'RootManageSharedAccessKey')]"
    ],
    "properties": {
      "displayName": "ServiceBusConnection",
      "customParameterValues": {},
      "api": {
        "id": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Web/locations/centralus/managedApis/', parameters('connections_servicebus_name'))]"
      },
      "parameterValues": {
        "connectionString": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/authorizationRules', parameters('ServiceBusNamespace'), 'RootManageSharedAccessKey'), '2017-04-01').primaryConnectionString]"
      }
    }
  }


来源:https://stackoverflow.com/questions/36799564/how-to-set-the-connection-string-for-a-service-bus-logic-app-action-in-an-arm-te

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!