Azure事件中心-在ARM模板中启用Kafka

时间:2018-07-26 12:46:57

标签: azure apache-kafka azure-eventhub

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

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

如果没有,是否可以使用PowerShell在事件中心上启用Kafka?

1 个答案:

答案 0 :(得分: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]"
        }
    }
}