创建 Azure 数据资源管理器群集和数据库
Azure 数据资源管理器是一项快速、完全托管的数据分析服务,用于实时分析从应用程序、网站和 IoT 设备等资源流式传输的海量数据。 若要使用 Azure 数据资源管理器,请先创建群集,再在该群集中创建一个或多个数据库。 然后,可将数据引入(加载)到数据库,并对其运行查询。
本文介绍如何使用 C#、Python、Go、Azure CLI、PowerShell 或 Azure 资源管理器 (ARM) 模板创建群集和数据库。 若要了解如何使用 Azure 门户创建群集和数据库,请参阅快速入门:创建 Azure 数据资源管理器群集和数据库。
有关基于以前的 SDK 版本的代码示例,请参阅存档的文章。
群集和数据库创建方法的先决条件:
本部分指导你完成创建 Azure 数据资源管理器群集的过程。 选择与你的首选方法相关的选项卡来创建群集。
若要了解如何使用 PowerShell 部署以下 ARM 模板,请参阅使用 ARM 模板。 或者,可以通过选择“部署到 Azure”,在 Azure 门户中部署模板。
可将此模板用于自己的部署,或自定义此模板以满足要求。 有关要在模板中使用的 JSON 语法和属性,请参阅 Microsoft.Kusto 资源类型。
{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"clusters_kustocluster_name": {
"type": "string",
"defaultValue": "[concat('kusto', uniqueString(resourceGroup().id))]",
"metadata": {
"description": "Name of the cluster to create"
}
},
"databases_kustodb_name": {
"type": "string",
"defaultValue": "kustodb",
"metadata": {
"description": "Name of the database to create"
}
},
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {},
"resources": [
{
"name": "[parameters('clusters_kustocluster_name')]",
"type": "Microsoft.Kusto/clusters",
"sku": {
"name": "Standard_D13_v2",
"tier": "Standard",
"capacity": 2
},
"apiVersion": "2022-12-29",
"location": "[parameters('location')]",
"tags": {
"Created By": "GitHub quickstart template"
},
"properties": {
"trustedExternalTenants": [],
"optimizedAutoscale": {
"version": 1,
"isEnabled": true,
"minimum": 2,
"maximum": 10
},
"enableDiskEncryption": false,
"enableStreamingIngest": false,
"virtualNetworkConfiguration": {
"subnetId": "<subnet resource id>",
"enginePublicIpId": "<Engine service's public IP address resource id>",
"dataManagementPublicIpId": "<Data management's service public IP address resource id>"
},
"keyVaultProperties": {
"keyName": "<Key name>",
"keyVaultUri": "<Key vault uri>",
"userIdentity": "<ResourceId of user assigned managed identity>"
},
"enablePurge": false,
"enableDoubleEncryption": false,
"engineType": "V3"
},
"identity": {
"type": "SystemAssigned, UserAssigned",
"userAssignedIdentities": {
"<ResourceId of managed identity>": {}
}
}
},
{
"name": "[concat(parameters('clusters_kustocluster_name'), '/', parameters('databases_kustodb_name'))]",
"type": "Microsoft.Kusto/clusters/databases",
"apiVersion": "2022-12-29",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Kusto/clusters', parameters('clusters_kustocluster_name'))]"
],
"properties": {
"softDeletePeriodInDays": 365,
"hotCachePeriodInDays": 31
}
}
]
}
以下步骤说明如何使用 PowerShell 部署 ARM 模板。
将以下代码复制到 PowerShell。
$projectName = Read-Host -Prompt "Enter a project name that is used for generating resource names" $location = Read-Host -Prompt "Enter the location (i.e. chinaeast2)" $resourceGroupName = "${projectName}rg" $clusterName = "${projectName}cluster" $parameters = @{} $parameters.Add("clusters_kustocluster_name", $clusterName) $templateUri = "https://azure.microsoft.com/resources/templates/kusto-cluster-database/" New-AzResourceGroup -Name $resourceGroupName -Location $location New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri -TemplateParameterObject $parameters Write-Host "Press [ENTER] to continue ..."
右键单击 shell 控制台并选择“粘贴” 。
备注
创建 Azure 数据资源管理器群集和数据库需要数分钟的时间。
若要验证部署,请使用以下 Azure PowerShell 脚本。
$projectName = Read-Host -Prompt "Enter the same project name that you used in the last procedure" Install-Module -Name Az.Kusto $resourceGroupName = "${projectName}rg" $clusterName = "${projectName}cluster" Get-AzKustoCluster -ResourceGroupName $resourceGroupName -Name $clusterName Write-Host "Press [ENTER] to continue ..."
在本部分,你将在上一部分中创建的群集内创建一个数据库。