快速入門:使用 Bicep 建立 Azure Synapse Analytics 專用 SQL 集區 (先前稱為 SQL DW)

Tip

Microsoft Fabric Data Warehouse 是一個企業規模的關聯式倉庫,建立在資料湖基礎上,具備未來準備架構、內建 AI 及新功能。 如果你是資料倉儲新手,建議先從Fabric Data Warehouse開始。 現有的 專用 SQL 工作負載可升級至 Fabric,以取得資料科學、即時分析與報告等多項新功能。

此 Bicep 檔案會建立已啟用 透明資料加密 的專用 SQL 集區(先前稱為 SQL DW)。 專用 SQL 集區(先前稱為 SQL DW)是指 Azure Synapse 中正式推出的企業數據倉儲功能。

Bicep 是使用宣告式語法來部署 Azure 資源的特定領域語言 (DSL)。 其提供簡潔的語法、可靠的類型安全,並支援程式碼重複使用。 Bicep 能夠為您在 Azure 中的基礎結構即程式碼解決方案,提供最佳的製作體驗。

必要條件

如果您沒有 Azure 訂用帳戶,請在開始前建立免費帳戶

檢閱 Bicep 檔案

此快速入門中使用的 Bicep 檔案是來自 Azure 快速入門範本

@description('The SQL Logical Server name.')
param sqlServerName string = 'sql${uniqueString(resourceGroup().id)}'

@description('The administrator username of the SQL Server.')
param sqlAdministratorLogin string

@description('The administrator password of the SQL Server.')
@secure()
param sqlAdministratorPassword string

@description('The name of the Database.')
param databasesName string

@description('Enable/Disable Transparent Data Encryption')
@allowed([
  'Enabled'
  'Disabled'
])
param transparentDataEncryption string = 'Enabled'

@description('DW Performance Level expressed in DTU (i.e. 900 DTU = DW100c)')
@minValue(900)
@maxValue(54000)
param capacity int

@description('The SQL Database collation.')
param databaseCollation string = 'SQL_Latin1_General_CP1_CI_AS'

@description('Resource location')
param location string = resourceGroup().location

resource sqlServer 'Microsoft.Sql/servers@2023-08-01-preview' = {
  name: sqlServerName
  location: location
  properties: {
    administratorLogin: sqlAdministratorLogin
    administratorLoginPassword: sqlAdministratorPassword
    version: '12.0'
    publicNetworkAccess: 'Enabled'
    minimalTlsVersion: '1.2'
    restrictOutboundNetworkAccess: 'Disabled'
  }
}

resource sqlServerDatabase 'Microsoft.Sql/servers/databases@2023-08-01-preview' = {
  parent: sqlServer
  name: databasesName
  location: location
  sku: {
    name: 'DataWarehouse'
    tier: 'DataWarehouse'
    capacity: capacity
  }
  properties: {
    collation: databaseCollation
    catalogCollation: databaseCollation
    readScale: 'Disabled'
    requestedBackupStorageRedundancy: 'Geo'
    isLedgerOn: false
  }
}

resource encryption 'Microsoft.Sql/servers/databases/transparentDataEncryption@2023-08-01-preview' = {
  parent: sqlServerDatabase
  name: 'current'
  properties: {
    state: transparentDataEncryption
  }
}

resource securityAlertPolicy 'Microsoft.Sql/servers/securityAlertPolicies@2023-08-01-preview' = {
  parent: sqlServer
  name: 'default'
  properties: {
    state: 'Enabled'
  }
}

resource auditingSetting 'Microsoft.Sql/servers/auditingSettings@2023-08-01-preview' = {
  parent: sqlServer
  name: 'default'
  properties: {
    isAzureMonitorTargetEnabled: true
    state: 'Enabled'
    retentionDays: 7
    auditActionsAndGroups: [
      'SUCCESSFUL_DATABASE_AUTHENTICATION_GROUP'
      'FAILED_DATABASE_AUTHENTICATION_GROUP'
      'BATCH_COMPLETED_GROUP'
    ]
  }
}

output location string = location
output name string = sqlServer.name
output resourceGroupName string = resourceGroup().name
output resourceId string = sqlServer.id

Bicep 檔案會定義一個資源:

部署 Bicep 檔案

  1. 將 Bicep 檔案以 main.bicep 儲存至本機電腦。

  2. 使用 Azure CLI 或 Azure PowerShell 部署 Bicep 檔案。

    az group create --name exampleRG --location eastus
    az deployment group create --resource-group exampleRG --template-file main.bicep --parameters sqlAdministratorLogin=<admin-login> databasesName=<db-name> capacity=<int>
    

    注意

    <admin-login> 替換為 SQL Server 的系統管理員登入用戶名稱。 將 <db-name> 替換為資料庫的名稱。 用 DW 效能等級替換<int>。 最小值為 900,最大值為 54000。 系統也會提示您輸入 sqlAdministratorPassword

當部署完成時,您應該會看到指出部署成功的訊息。

檢閱已部署的資源

使用 Azure 入口網站、Azure CLI 或 Azure PowerShell 來列出資源群組中已部署的資源。

az resource list --resource-group exampleRG

清除資源

不再需要時,請使用 Azure 入口網站、Azure CLI 或 Azure PowerShell 來刪除資源群組及其資源。

az group delete --name exampleRG

下一步

在本快速入門中,您已使用 Bicep 建立專用 SQL 集區(先前稱為 SQL DW),並驗證部署。 若要深入瞭解 Azure Synapse Analytics 和 Bicep,請參閱下列文章。