Why does my ARM template, fail to create authorization rules consistently?

Sandesh

I have created an ARM template for deploying Azure Service Bus which also includes event hub and queues. The template creates the queues and event hubs successfully but some times the authorization rules some how is not created (20% of the time). Below is the trimmed version of the template which I have created after a struggle :P.

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "type": "string",
            "defaultValue": "South Central US",
            "metadata": {
                "description": "The location where all azure resources will be deployed."
            }
        },
        "serviceBusNamespace": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "The name of the service bus namespace to create."
            }
        },
        "queueName": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "The name of the queue to create."
            }
        },
        "hubName": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "The name of the event hub to create."
            }
        },
        "messagingSku": {
            "type": "int",
            "minValue": 1,
            "defaultValue": 1,
            "metadata": {
                "description": "The SKU version."
            }
        },
        "queueMaxSizeInGB": {
            "type": "int",
            "minValue": 1,
            "defaultValue": 1,
            "maxValue": 16,
            "metadata": {
                "description": "The queue max size."
            }
        },
        "partitionCount": {
            "type": "int",
            "minValue": 2,
            "defaultValue": 2,
            "maxValue": 32,
            "metadata": {
                "description": "The partition count of event hub."
            }
        }
    },
    "variables": {
        "queueSize": "[mul(parameters('queueMaxSizeInGB'),1024)]",
        "managePolicy": "ManagePolicy",
        "sendPolicy": "SendPolicy",
        "listenPolicy": "ListenPolicy"
    },
    "resources": [
        {
            "apiVersion": "2014-09-01",
            "name": "[parameters('serviceBusNamespace')]",
            "type": "Microsoft.ServiceBus/namespaces",
            "location": "[parameters('location')]",
            "properties": {
                "messagingSku": "[parameters('messagingSku')]"
            },
            "resources": [
                {
                    "apiVersion": "2014-09-01",
                    "name": "[parameters('queueName')]",
                    "type": "Queues",
                    "dependsOn": [
                        "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'))]"
                    ],
                    "properties": {
                        "path": "[parameters('queueName')]",
                        "maxSizeInMegabytes": "[variables('queueSize')]"
                    },
                    "resources": [
                        {
                            "apiVersion": "2015-08-01",
                            "name": "[variables('managePolicy')]",
                            "type": "authorizationRules",
                            "dependsOn": [
                                "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'))]"
                            ],
                            "properties": {
                                "Rights": [
                                    "Send",
                                    "Listen",
                                    "Manage"
                                ]
                            }
                        },
                        {
                            "apiVersion": "2015-08-01",
                            "name": "[variables('sendPolicy')]",
                            "type": "authorizationRules",
                            "dependsOn": [
                                "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'))]"
                            ],
                            "properties": {
                                "Rights": [
                                    "Send"
                                ]
                            }
                        },
                        {
                            "apiVersion": "2015-08-01",
                            "name": "[variables('listenPolicy')]",
                            "type": "authorizationRules",
                            "dependsOn": [
                                "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'))]"
                            ],
                            "properties": {
                                "Rights": [
                                    "Listen"
                                ]
                            }
                        }
                    ]
                },
                {
                    "apiVersion": "2014-09-01",
                    "name": "[parameters('hubName')]",
                    "type": "EventHubs",
                    "dependsOn": [
                        "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'))]"
                    ],
                    "properties": {
                        "path": "[parameters('hubName')]",
                        "partitionCount": "[parameters('partitionCount')]"
                    }
                }
            ]
        }
    ],
    "outputs": {
        "queueManagePolicy": {
            "type": "string",
            "value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/queues/authorizationRules',parameters('serviceBusNamespace'),parameters('queueName'),variables('managePolicy')),'2015-08-01').primaryConnectionString]"
        },
        "queueSendPolicy": {
            "type": "string",
            "value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/queues/authorizationRules',parameters('serviceBusNamespace'),parameters('queueName'),variables('sendPolicy')),'2015-08-01').primaryConnectionString]"
        },
        "queueListenPolicy": {
            "type": "string",
            "value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/queues/authorizationRules',parameters('serviceBusNamespace'),parameters('queueName'),variables('listenPolicy')),'2015-08-01').primaryConnectionString]"
        }
    }
}

Is somebody also having the same issue or I am missing something silly? Is there a fix?

Any help is greatly appreciated.

Sandesh

MS helped me resolve the issue. The problem was that the authorization rules were getting created in parallel which RM does not like. The way to fix it is to simply create the SAS tokens one by one. Below is the consistently working ARM template

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "type": "string",
            "defaultValue": "South Central US",
            "metadata": {
                "description": "The location where all azure resources will be deployed."
            }
        },
        "serviceBusNamespace": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "The name of the service bus namespace to create."
            }
        },
        "queueName": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "The name of the queue to create."
            }
        },
        "hubName": {
            "type": "string",
            "minLength": 1,
            "metadata": {
                "description": "The name of the event hub to create."
            }
        },
        "messagingSku": {
            "type": "int",
            "minValue": 1,
            "defaultValue": 1,
            "metadata": {
                "description": "The SKU version."
            }
        },
        "queueMaxSizeInGB": {
            "type": "int",
            "minValue": 1,
            "defaultValue": 1,
            "maxValue": 16,
            "metadata": {
                "description": "The queue max size."
            }
        },
        "partitionCount": {
            "type": "int",
            "minValue": 2,
            "defaultValue": 2,
            "maxValue": 32,
            "metadata": {
                "description": "The partition count of event hub."
            }
        }
    },
    "variables": {
        "queueSize": "[mul(parameters('queueMaxSizeInGB'),1024)]",
        "managePolicy": "ManagePolicy",
        "sendPolicy": "SendPolicy",
        "listenPolicy": "ListenPolicy"
    },
    "resources": [
        {
            "apiVersion": "2014-09-01",
            "name": "[parameters('serviceBusNamespace')]",
            "type": "Microsoft.ServiceBus/namespaces",
            "location": "[parameters('location')]",
            "properties": {
                "messagingSku": "[parameters('messagingSku')]"
            },
            "resources": [
                {
                    "apiVersion": "2014-09-01",
                    "name": "[parameters('queueName')]",
                    "type": "Queues",
                    "dependsOn": [
                        "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'))]"
                    ],
                    "properties": {
                        "path": "[parameters('queueName')]",
                        "maxSizeInMegabytes": "[variables('queueSize')]"
                    },
                    "resources": [
                        {
                            "apiVersion": "2015-08-01",
                            "name": "[variables('managePolicy')]",
                            "type": "authorizationRules",
                            "dependsOn": [
                                "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'))]"
                            ],
                            "properties": {
                                "Rights": [
                                    "Send",
                                    "Listen",
                                    "Manage"
                                ]
                            }
                        },
                        {
                            "apiVersion": "2015-08-01",
                            "name": "[variables('sendPolicy')]",
                            "type": "authorizationRules",
                            "dependsOn": [
                                "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'))]",
                                "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'), '/authorizationRules/', variables('managePolicy'))]",
                            ],
                            "properties": {
                                "Rights": [
                                    "Send"
                                ]
                            }
                        },
                        {
                            "apiVersion": "2015-08-01",
                            "name": "[variables('listenPolicy')]",
                            "type": "authorizationRules",
                            "dependsOn": [
                                "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'))]",
                                "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'), '/authorizationRules/', variables('managePolicy'))]",
                                "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'),'/queues/',parameters('queueName'), '/authorizationRules/', variables('sendPolicy'))]"
                            ],
                            "properties": {
                                "Rights": [
                                    "Listen"
                                ]
                            }
                        }
                    ]
                },
                {
                    "apiVersion": "2014-09-01",
                    "name": "[parameters('hubName')]",
                    "type": "EventHubs",
                    "dependsOn": [
                        "[concat('Microsoft.ServiceBus/namespaces/', parameters('serviceBusNamespace'))]"
                    ],
                    "properties": {
                        "path": "[parameters('hubName')]",
                        "partitionCount": "[parameters('partitionCount')]"
                    }
                }
            ]
        }
    ],
    "outputs": {
        "queueManagePolicy": {
            "type": "string",
            "value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/queues/authorizationRules',parameters('serviceBusNamespace'),parameters('queueName'),variables('managePolicy')),'2015-08-01').primaryConnectionString]"
        },
        "queueSendPolicy": {
            "type": "string",
            "value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/queues/authorizationRules',parameters('serviceBusNamespace'),parameters('queueName'),variables('sendPolicy')),'2015-08-01').primaryConnectionString]"
        },
        "queueListenPolicy": {
            "type": "string",
            "value": "[listKeys(resourceId('Microsoft.ServiceBus/namespaces/queues/authorizationRules',parameters('serviceBusNamespace'),parameters('queueName'),variables('listenPolicy')),'2015-08-01').primaryConnectionString]"
        }
    }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why does plymouth fail consistently after booting into second OS?

From Dev

Why does my NSMutableURLRequest fail?

From Dev

Why does SWIG fail to parse a template / struct?

From Dev

Why are my if statements not working consistently?

From Dev

Why does loadedmetadata not consistently fire

From Dev

Why does loadedmetadata not consistently fire

From Dev

Why does arm::standardize() fail to work on a lm object in a loop?

From Java

Why does assembly binding fail in my project?

From Dev

Why does my cross-compiling fail?

From Dev

Why does my redirected CORS request fail?

From Dev

Why does my rspec test fail?

From Dev

Why does my kernel fail to build?

From Dev

Why does my linq to sql query fail?

From Dev

Why does my pointer arithmetic fail in this array

From Dev

Why does my wifi fail to stay connected?

From Dev

Why does my jasmine tests fail on this directive?

From Dev

Why does my Vapor query always fail?

From Dev

Why Does My FAMILY Query Fail?

From Dev

Why does my metaclass implementation fail with a TypeError about not being able to create NoneType instances

From Dev

Why does my Rspec post :create invalid parameter controller test fail?

From Dev

Why does an empty 200 create a fail in jQuery?

From Dev

Why does Laravel fail to create a model relation?

From Dev

Why is my css Class not being applied consistently?

From Dev

Why does the variadic template argument deduction fail for this function pointer?

From Dev

C++ why does SFINAE fail with only a class template parameter?

From Dev

Why does template parameter deduction fail when calling the constructor like this?

From Dev

Why does Excel not recognise and format dates consistently?

From Dev

Why does compilation fail when a function template calls a static method template of a class template?

From Dev

After renaming a model, why do my create and update functions fail?

Related Related

  1. 1

    Why does plymouth fail consistently after booting into second OS?

  2. 2

    Why does my NSMutableURLRequest fail?

  3. 3

    Why does SWIG fail to parse a template / struct?

  4. 4

    Why are my if statements not working consistently?

  5. 5

    Why does loadedmetadata not consistently fire

  6. 6

    Why does loadedmetadata not consistently fire

  7. 7

    Why does arm::standardize() fail to work on a lm object in a loop?

  8. 8

    Why does assembly binding fail in my project?

  9. 9

    Why does my cross-compiling fail?

  10. 10

    Why does my redirected CORS request fail?

  11. 11

    Why does my rspec test fail?

  12. 12

    Why does my kernel fail to build?

  13. 13

    Why does my linq to sql query fail?

  14. 14

    Why does my pointer arithmetic fail in this array

  15. 15

    Why does my wifi fail to stay connected?

  16. 16

    Why does my jasmine tests fail on this directive?

  17. 17

    Why does my Vapor query always fail?

  18. 18

    Why Does My FAMILY Query Fail?

  19. 19

    Why does my metaclass implementation fail with a TypeError about not being able to create NoneType instances

  20. 20

    Why does my Rspec post :create invalid parameter controller test fail?

  21. 21

    Why does an empty 200 create a fail in jQuery?

  22. 22

    Why does Laravel fail to create a model relation?

  23. 23

    Why is my css Class not being applied consistently?

  24. 24

    Why does the variadic template argument deduction fail for this function pointer?

  25. 25

    C++ why does SFINAE fail with only a class template parameter?

  26. 26

    Why does template parameter deduction fail when calling the constructor like this?

  27. 27

    Why does Excel not recognise and format dates consistently?

  28. 28

    Why does compilation fail when a function template calls a static method template of a class template?

  29. 29

    After renaming a model, why do my create and update functions fail?

HotTag

Archive