在arm模板中启用kafka

cs7cruho  于 2021-06-08  发布在  Kafka
关注(0)|答案(1)|浏览(411)

我想在启用kafka的azure中自动部署事件中心。
“microsoft.eventhub/namespaces”资源中是否有arm模板属性可用于启用kafka?
如果没有,是否有方法使用powershell在事件中心启用kafka?

jutyujz0

jutyujz01#

这个 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]"
        }
    }
}

相关问题