Reputation: 63
We have 2 different Azure SQL managed instance servers.
The point in time restore source server is located in the west us region in its own resource group (rg-sqlmi-source)
The target server is located in the east us region in a separate resource group (rg-sqlmi-target)
I can do the point in time restores between these servers using the azure portal just fine but when trying to do it using bicep I get an error saying that the source server does not exist.
Here is my bicep code: main.bicep
param location string = resourceGroup().location
resource sourceManagedInstance 'Microsoft.Sql/managedInstances@2021-11-01-preview' existing = {
name: 'sqlmi-source-server'
scope: resourceGroup('my-subscription-id', 'rg-sqlmi-source')
}
resource sourceDatabase 'Microsoft.Sql/managedInstances/databases@2022-11-01-preview' existing = {
parent: sourceManagedInstance
name: 'MySourceDBName'
}
module newDBMod './newDB.bicep' = {
name: 'newDBDeployment'
scope: resourceGroup('my-subscription-id', 'rg-sqlmi-target')
params: {
location: location
sourcesqlMIId: sourceDatabase.id
}
}
newDB.bicep module
param sourcesqlMIId string
param location string
resource managedInstance 'Microsoft.Sql/managedInstances@2021-11-01-preview' existing = {
name: 'sqlmi-target-server'//deploymentInstanceName
}
resource database 'Microsoft.Sql/managedInstances/databases@2021-11-01-preview' = {
parent: managedInstance
location: location
name: 'Test_Restore_DB'
properties: {
createMode: 'PointInTimeRestore'
restorePointInTime: '2025-01-28 15:00:00'
sourceDatabaseId: sourcesqlMIId
}
tags: {
createdBy: 'Me'
Department: 'Dev'
}
}
both files uploaded to my azure powershell and run with the following command
new-AzResourceGroupDeployment -TemplateFile ./main.bicep -ResourceGroupName rg-sqlmi-target
Thank you for any help on this!
Upvotes: 0
Views: 71