【问题标题】:Azure Event Hub - Enable Kafka in ARM templateAzure 事件中心 - 在 ARM 模板中启用 Kafka
【发布时间】:2018-07-26 12:46:57
【问题描述】:

我想在启用 Kafka 的情况下自动在 Azure 中部署事件中心。

“Microsoft.EventHub/namespaces”资源上是否有可用于启用 Kafka 的 ARM 模板属性?

如果没有,有没有办法使用 PowerShell 在事件中心启用 Kafka?

【问题讨论】:

    标签: azure apache-kafka azure-eventhub


    【解决方案1】:

    kafkaEnabled 处于预览阶段,但实际上您可以通过 ARM 模板启用它。

    只需参考下面的示例模板,它对我来说效果很好。

    {
        "$schema": "http://schema.management.azure.com/schemas/2014-04-01-preview/deploymentTemplate.json#",
        "contentVersion": "1.0.0.0",
        "parameters": {
            "kafkaEnabled":{
                "type":"bool"
                },
            "namespaceName": {
                "type": "string",
                "metadata": {
                    "description": "Name of EventHub namespace"
                }
            },
            "eventhubSku": {
                "type": "string",
                "allowedValues": [
                    "Basic",
                    "Standard"
                ],
                "defaultValue": "Standard",
                "metadata": {
                    "description": "The messaging tier for service Bus namespace"
                }
            },
            "skuCapacity": {
                "type": "int",
                "allowedValues": [
                    1,
                    2,
                    4
                ],
                "defaultValue": 1,
                "metadata": {
                    "description": "MessagingUnits for premium namespace"
                }
            },
            "eventHubName": {
                "type": "string",
                "metadata": {
                    "description": "Name of Event Hub"
                }
            },
            "consumerGroupName": {
                "type": "string",
                "metadata": {
                    "description": "Name of Consumer Group"
                }
            },
            "location": {
                "type": "string",
                "defaultValue": "[resourceGroup().location]",
                "metadata": {
                    "description": "Location for all resources."
                }
            }
        },
        "variables": {
            "defaultSASKeyName": "RootManageSharedAccessKey",
            "authRuleResourceId": "[resourceId('Microsoft.EventHub/namespaces/authorizationRules', parameters('namespaceName'), variables('defaultSASKeyName'))]"
        },
        "resources": [
            {
                "apiVersion": "2017-04-01",
                "name": "[parameters('namespaceName')]",
                "type": "Microsoft.EventHub/Namespaces",
                "location": "[parameters('location')]",
                "sku": {
                    "name": "[parameters('eventhubSku')]",
                    "tier": "[parameters('eventhubSku')]",
                    "capacity": "[parameters('skuCapacity')]"
                },
                "properties": {
                        "kafkaEnabled":"[parameters('kafkaEnabled')]"
                },
                "resources": [
                    {
                        "apiVersion": "2017-04-01",
                        "name": "[parameters('eventHubName')]",
                        "type": "EventHubs",
                        "dependsOn": [
                            "[concat('Microsoft.EventHub/namespaces/', parameters('namespaceName'))]"
                        ],
                        "properties": {},
                        "resources": [
                            {
                                "apiVersion": "2017-04-01",
                                "name": "[parameters('consumerGroupName')]",
                                "type": "ConsumerGroups",
                                "dependsOn": [
                                    "[parameters('eventHubName')]"
                                ],
                                "properties": {
                                    "userMetadata": "User Metadata goes here"
                                }
                            }
                        ]
                    }
                ]
            }
        ],
        "outputs": {
            "NamespaceConnectionString": {
                "type": "string",
                "value": "[listkeys(variables('authRuleResourceId'), '2017-04-01').primaryConnectionString]"
            },
            "SharedAccessPolicyPrimaryKey": {
                "type": "string",
                "value": "[listkeys(variables('authRuleResourceId'), '2017-04-01').primaryKey]"
            }
        }
    }
    

    【讨论】:

    • 谢谢!我确实需要将 apiVersion 更改为“2018-01-01-preview”以使其适合我。
    • 如果 kafkaEnabled 值周围有引号,例如“kafkaEnabled”:“false”或只是原始的“kafkaEnabled”:false?我已经尝试了所有方法,门户网站总是将 Kafka Surface 显示为已启用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-06-12
    • 2019-11-05
    • 1970-01-01
    • 2019-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多