4

I have an event hub that looks like this: enter image description here

enter image description here

enter image description here

enter image description here

I have successfully done it for service bus, but only for the high level RootManageSharedAccessKey.

However with Event Hub I want the primary connection string for the SendOnly shared access policy.

I have tried many combinations but I when I deploy the deployment cant find the SendOnly shared access policy.

Here is the json for my SendOnly shared access policy.

enter image description here

Any help will be greatly appreciated.

0

3 Answers 3

13

The final working ARM template code was:

[listkeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', variables('ehub').name, parameters('eventhubs_myaccountevents_name'), 'SendOnly'), parameters('eventhubs_api_version')).primaryConnectionString]

Note that instead of this:

Microsoft.Eventhub/namespaces/authorizationRules

I had to use this:

Microsoft.EventHub/namespaces/eventhubs/authorizationRules

Here is the sample I used: https://github.com/pascalnaber/EnterpriseARMTemplates/blob/6babc4d3e65f10f999bb144a1d616ccb2a085e9d/templates/resources/Microsoft.Eventhub/azuredeploy.json

7

use this to get the connection string:

"[listkeys(resourceId('Microsoft.Eventhub/namespaces/authorizationRules',
  parameters('name'), 'RootManageSharedAccessKey'),
  '2017-04-01').primaryConnectionString]"

you cannot split it across lines, i've done that for sake of readibility

8
  • But that's the root connection string. I need the send only
    – RuSs
    Nov 19, 2017 at 10:58
  • 1
    replace 'RootManageSharedAccessKey' with 'SendOnly'?
    – 4c74356b41
    Nov 19, 2017 at 11:37
  • I also had to add another resourceid section in between namespaces and authorizationRules: [listkeys(resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', variables('ehub').name, parameters('eventhubs_myaccountevents_name'), 'SendOnly'), parameters('eventhubs_api_version')).primaryConnectionString]
    – RuSs
    Nov 19, 2017 at 22:15
  • well, you could at least upvote my answer, as its the right one, technically ;)
    – 4c74356b41
    Nov 20, 2017 at 6:23
  • Sorry man I have done that now. Are you saying yours works as well if I just replace RootConnectionShar.... If so why do they both work?
    – RuSs
    Nov 20, 2017 at 6:42
2

This is how I solved it (including creating the authorization rule):

Define the variables:

...
"variables": {
    "eventHubNamespaceName": "myehubns",
    "eventHubName": "myehub",
    "eventhubSendAuthorizationRuleName": "SendOnly",
    "eventHubSendRuleId": "[resourceId('Microsoft.EventHub/namespaces/eventhubs/authorizationRules', variables('eventHubNamespaceName'),variables('eventHubName'), variables('eventhubSendAuthorizationRuleName'))]"
}

Create the Authorization Rule:

...
"resources": [{
        "apiVersion": "2017-04-01",
        "name": "[variables('eventhubSendAuthorizationRuleName')]",
        "type": "authorizationRules",
        "dependsOn": [
            "[concat('Microsoft.EventHub/namespaces/', variables('eventHubNamespaceName'),'/eventhubs/',variables('eventHubName'))]"
        ],
        "properties": {
            "rights": [
                "Send"
            ]
        }
    }
]

Retrieve the primary Connection String of the previous created rule:

"EventHubConnectionstring": "[listkeys(variables('eventHubSendRuleId'), '2017-04-01').primaryConnectionString]"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.