Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Sql server restructured #317

Merged
merged 13 commits into from
Nov 3, 2021
Merged
214 changes: 0 additions & 214 deletions .github/workflows/ms.sql.servers.databases.yml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"$schema": "http://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"applicationGatewayName": {
Expand Down
9 changes: 7 additions & 2 deletions arm/Microsoft.Sql/servers/.bicep/nested_rbac.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@ param roleAssignmentObj object
param builtInRoleNames object
param resourceName string

resource roleAssignment 'Microsoft.Sql/servers/providers/roleAssignments@2021-04-01-preview' = [for principalId in roleAssignmentObj.principalIds: {
name: '${resourceName}/Microsoft.Authorization/${guid(resourceName, principalId, roleAssignmentObj.roleDefinitionIdOrName)}'
resource server 'Microsoft.Sql/servers@2020-02-02-preview' existing = {
name: resourceName
}

resource roleAssignment 'Microsoft.Authorization/roleAssignments@2021-04-01-preview' = [for principalId in roleAssignmentObj.principalIds: {
name: guid(server.name, principalId, roleAssignmentObj.roleDefinitionIdOrName)
properties: {
roleDefinitionId: (contains(builtInRoleNames, roleAssignmentObj.roleDefinitionIdOrName) ? builtInRoleNames[roleAssignmentObj.roleDefinitionIdOrName] : roleAssignmentObj.roleDefinitionIdOrName)
principalId: principalId
}
scope: server
}]
14 changes: 13 additions & 1 deletion arm/Microsoft.Sql/servers/.parameters/parameters.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"location": {
"value": "westeurope"
},
"serverName": {
"name": {
"value": "sxx-az-sqlsrv-x-001"
},
"roleAssignments": {
Expand All @@ -36,6 +36,18 @@
]
}
]
},
"databases": {
"value": [
{
"name": "sxx-az-sqldb-weu-x-001",
"collation": "SQL_Latin1_General_CP1_CI_AS",
"tier": "GeneralPurpose",
"skuName": "GP_Gen5_2",
"maxSizeBytes": 34359738368,
"licenseType": "LicenseIncluded"
}
]
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
param collation string

@description('Required. The name of the database.')
param databaseName string
param name string

@description('Optional. The tier or edition of the particular SKU.')
param tier string
Expand All @@ -26,10 +26,14 @@ param zoneRedundant bool = false
param licenseType string = ''

@description('Optional. The state of read-only routing.')
param readScaleOut string = 'Disabled'
@allowed([
'Enabled'
'Disabled'
])
param readScale string = 'Disabled'

@description('Optional. The number of readonly secondary replicas associated with the database.')
param numberOfReplicas int = 0
param highAvailabilityReplicaCount int = 0

@description('Optional. Minimal capacity that database will always have allocated.')
param minCapacity string = ''
Expand All @@ -56,7 +60,7 @@ param cuaId string = ''
param requestedBackupStorageRedundancy string = ''

@description('Optional. Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created.')
param enableSqlLedger bool = false
param isLedgerOn bool = false

@description('Optional. Maintenance configuration id assigned to the database. This configuration defines the period when the maintenance updates will occur.')
param maintenanceConfigurationId string = ''
Expand All @@ -66,22 +70,22 @@ module pid_cuaId '.bicep/nested_cuaId.bicep' = if (!empty(cuaId)) {
params: {}
}

resource sqlServerDatabase 'Microsoft.Sql/servers/databases@2021-02-01-preview' = {
resource database 'Microsoft.Sql/servers/databases@2021-02-01-preview' = {
location: location
tags: tags
name: '${serverName}/${databaseName}'
name: '${serverName}/${name}'
properties: {
collation: collation
maxSizeBytes: maxSizeBytes
sampleName: sampleName
zoneRedundant: zoneRedundant
licenseType: licenseType
readScale: readScaleOut
readScale: readScale
minCapacity: !empty(minCapacity) ? json(minCapacity) : 0
autoPauseDelay: !empty(autoPauseDelay) ? json(autoPauseDelay) : 0
highAvailabilityReplicaCount: numberOfReplicas
highAvailabilityReplicaCount: highAvailabilityReplicaCount
requestedBackupStorageRedundancy: any(requestedBackupStorageRedundancy)
isLedgerOn: enableSqlLedger
isLedgerOn: isLedgerOn
maintenanceConfigurationId: !empty(maintenanceConfigurationId) ? maintenanceConfigurationId : null
}
sku: {
Expand All @@ -90,6 +94,11 @@ resource sqlServerDatabase 'Microsoft.Sql/servers/databases@2021-02-01-preview'
}
}

output databaseName string = databaseName
@description('The name of the deployed database')
output databaseName string = database.name

@description('The resourceId of the deployed database')
output databaseId string = database.id

@description('The resourceGroup of the deployed database')
output databaseResourceGroup string = resourceGroup().name
output serverName string = serverName
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AzureSQLDatabase `[Microsoft.Sql/servers/databases]`
# SQL Server Database `[Microsoft.Sql/servers/databases]`

This module deploys an Azure SQL Server.

Expand All @@ -15,15 +15,15 @@ This module deploys an Azure SQL Server.
| `autoPauseDelay` | string | | | Optional. Time in minutes after which database is automatically paused. |
| `collation` | string | | | Optional. The collation of the database. |
| `cuaId` | string | | | Optional. Customer Usage Attribution id (GUID). This GUID must be previously registered |
| `databaseName` | string | | | Required. The name of the database. |
| `enableSqlLedger` | bool | | | Optional. Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created. |
| `highAvailabilityReplicaCount` | int | | | Optional. The number of readonly secondary replicas associated with the database. |
| `isLedgerOn` | bool | | | Optional. Whether or not this database is a ledger database, which means all tables in the database are ledger tables. Note: the value of this property cannot be changed after the database has been created. |
| `licenseType` | string | | | Optional. The license type to apply for this database. |
| `location` | string | `[resourceGroup().location]` | | Optional. Location for all resources. |
| `maintenanceConfigurationId` | string | | | Optional. Maintenance configuration id assigned to the database. This configuration defines the period when the maintenance updates will occur. |
| `maxSizeBytes` | int | | | Optional. The max size of the database expressed in bytes. |
| `minCapacity` | string | | | Optional. Minimal capacity that database will always have allocated. |
| `numberOfReplicas` | int | | | Optional. The number of readonly secondary replicas associated with the database. |
| `readScaleOut` | string | `Disabled` | | Optional. The state of read-only routing. |
| `name` | string | | | Required. The name of the database. |
| `readScale` | string | `Disabled` | `[Enabled, Disabled]` | Optional. The state of read-only routing. |
| `requestedBackupStorageRedundancy` | string | | `[Geo, Local, Zone, ]` | Optional. The storage account type to be used to store backups for this database. |
| `sampleName` | string | | | Optional. The name of the sample schema to apply when creating this database. |
| `serverName` | string | | | Required. The Name of SQL Server |
Expand Down Expand Up @@ -51,11 +51,11 @@ Tag names and tag values can be provided as needed. A tag can be left without a

## Outputs

| Output Name | Type |
| :-- | :-- |
| `databaseName` | string |
| `databaseResourceGroup` | string |
| `serverName` | string |
| Output Name | Type | Description |
| :-- | :-- | :-- |
| `databaseId` | string | The resourceId of the deployed database |
| `databaseName` | string | The name of the deployed database |
| `databaseResourceGroup` | string | The resourceGroup of the deployed database |

## Template references

Expand Down
Loading