Catatan
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba masuk atau mengubah direktori.
Akses ke halaman ini memerlukan otorisasi. Anda dapat mencoba mengubah direktori.
Panduan cepat ini berfokus pada proses penyebaran file Bicep untuk membuat Azure SQL Managed Instance dan vNet. Azure SQL Managed Instance adalah database cloud cerdas, dikelola sepenuhnya, dan dapat diskalakan, dengan paritas fitur hampir 100% dengan mesin database SQL Server.
Bicep adalah bahasa khusus domain (DSL) yang menggunakan sintaksis deklaratif untuk menyebarkan sumber daya Azure. Ini menyediakan sintaks yang ringkas, keamanan jenis yang dapat diandalkan, dan dukungan untuk penggunaan kembali kode. Bicep menawarkan pengalaman penulisan terbaik untuk solusi infrastruktur sebagai kode Anda di Azure.
Prasyarat
- Langganan Azure. Jika Anda tidak memiliki langganan Azure, membuat akun gratis
- Dalam kasus umum, pengguna Anda harus diberi peran Kontributor SQL Managed Instance dalam lingkup langganan.
- Jika melakukan provisi dalam subnet yang telah didelegasikan ke Azure SQL Managed Instance, pengguna Anda hanya memerlukan izin Microsoft.Sql/managedInstances/write yang ditetapkan pada tingkat langganan.
Meninjau file Bicep
File Bicep yang digunakan dalam Mulai Cepat ini terdapat di Templat Mulai Cepat Azure.
@description('Enter managed instance name.')
param managedInstanceName string
@description('Enter user name.')
param administratorLogin string
@description('Enter password.')
@secure()
param administratorLoginPassword string
@description('Enter location. If you leave this field blank resource group location would be used.')
param location string = resourceGroup().location
@description('Enter virtual network name. If you leave this field blank name will be created by the template.')
param virtualNetworkName string = 'SQLMI-VNET'
@description('Enter virtual network address prefix.')
param addressPrefix string = '10.0.0.0/16'
@description('Enter subnet name.')
param subnetName string = 'ManagedInstance'
@description('Enter subnet address prefix.')
param subnetPrefix string = '10.0.0.0/24'
@description('Enter sku name.')
@allowed([
'GP_Gen5'
'BC_Gen5'
])
param skuName string = 'GP_Gen5'
@description('Enter number of vCores.')
@allowed([
4
8
16
24
32
40
64
80
])
param vCores int = 16
@description('Enter storage size.')
@minValue(32)
@maxValue(8192)
param storageSizeInGB int = 256
@description('Enter license type.')
@allowed([
'BasePrice'
'LicenseIncluded'
])
param licenseType string = 'LicenseIncluded'
var networkSecurityGroupName = 'SQLMI-${managedInstanceName}-NSG'
var routeTableName = 'SQLMI-${managedInstanceName}-Route-Table'
resource networkSecurityGroup 'Microsoft.Network/networkSecurityGroups@2021-08-01' = {
name: networkSecurityGroupName
location: location
properties: {
securityRules: [
{
name: 'allow_tds_inbound'
properties: {
description: 'Allow access to data'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '1433'
sourceAddressPrefix: 'VirtualNetwork'
destinationAddressPrefix: '*'
access: 'Allow'
priority: 1000
direction: 'Inbound'
}
}
{
name: 'allow_redirect_inbound'
properties: {
description: 'Allow inbound redirect traffic to Managed Instance inside the virtual network'
protocol: 'Tcp'
sourcePortRange: '*'
destinationPortRange: '11000-11999'
sourceAddressPrefix: 'VirtualNetwork'
destinationAddressPrefix: '*'
access: 'Allow'
priority: 1100
direction: 'Inbound'
}
}
{
name: 'deny_all_inbound'
properties: {
description: 'Deny all other inbound traffic'
protocol: '*'
sourcePortRange: '*'
destinationPortRange: '*'
sourceAddressPrefix: '*'
destinationAddressPrefix: '*'
access: 'Deny'
priority: 4096
direction: 'Inbound'
}
}
{
name: 'deny_all_outbound'
properties: {
description: 'Deny all other outbound traffic'
protocol: '*'
sourcePortRange: '*'
destinationPortRange: '*'
sourceAddressPrefix: '*'
destinationAddressPrefix: '*'
access: 'Deny'
priority: 4096
direction: 'Outbound'
}
}
]
}
}
resource routeTable 'Microsoft.Network/routeTables@2021-08-01' = {
name: routeTableName
location: location
properties: {
disableBgpRoutePropagation: false
}
}
resource virtualNetwork 'Microsoft.Network/virtualNetworks@2021-08-01' = {
name: virtualNetworkName
location: location
properties: {
addressSpace: {
addressPrefixes: [
addressPrefix
]
}
subnets: [
{
name: subnetName
properties: {
addressPrefix: subnetPrefix
routeTable: {
id: routeTable.id
}
networkSecurityGroup: {
id: networkSecurityGroup.id
}
delegations: [
{
name: 'managedInstanceDelegation'
properties: {
serviceName: 'Microsoft.Sql/managedInstances'
}
}
]
}
}
]
}
}
resource managedInstance 'Microsoft.Sql/managedInstances@2021-11-01-preview' = {
name: managedInstanceName
location: location
sku: {
name: skuName
}
identity: {
type: 'SystemAssigned'
}
dependsOn: [
virtualNetwork
]
properties: {
administratorLogin: administratorLogin
administratorLoginPassword: administratorLoginPassword
subnetId: resourceId('Microsoft.Network/virtualNetworks/subnets', virtualNetworkName, subnetName)
storageSizeInGB: storageSizeInGB
vCores: vCores
licenseType: licenseType
}
}
Sumber daya ini didefinisikan dalam file Bicep:
- Microsoft.Network/networkSecurityGroups
- Microsoft.Network/routeTables
- Microsoft.Network/virtualNetworks
- Microsoft.Sql/managedinstances
Menyebarkan file Bicep
Simpan file Bicep sebagai main.bicep ke komputer lokal Anda.
Sebarkan file Bicep menggunakan Azure CLI atau Azure PowerShell.
az group create --name exampleRG --location eastus az deployment group create --resource-group exampleRG --template-file main.bicep --parameters managedInstanceName=<instance-name> administratorLogin=<admin-login>
Nota
Ganti
Setelah penyebaran selesai, Anda akan melihat pesan yang menunjukkan penyebaran berhasil.
Meninjau sumber daya yang disebarkan
Gunakan portal Microsoft Azure, Azure CLI, atau Azure PowerShell untuk mencantumkan sumber daya yang disebarkan dalam grup sumber daya.
az resource list --resource-group exampleRG
Membersihkan sumber daya
Jika tidak lagi diperlukan, gunakan portal Microsoft Azure, Azure CLI, atau Azure PowerShell untuk menghapus grup sumber daya dan sumber dayanya.
az group delete --name exampleRG