Hi All,
I am trying to build a nightly refresh process for SQL Server DB from on premise to Azure Cloud (IAAS). The Azure infrastructure is configured as 2 node always on. Every Day a new DB get created with retention period of 7 days. (Another script which deletes old DB)
Nightly Build Process as Below:
1)DB Backup get copied to Azure Blob Storage
2)Restore DB on primary Server on Azure
3)Change DB owner to appropriate login on primary Server
4)Backup DB/Log from primary Server and restore it on Secondary Server.
5)Add DB to alwayson temp Group.
6)Failover temp Group and change DB owner to appropriate login. (Application Dependency to have login ID as the owner of the DB).
7)Failback and remove DB from temp group and add it to appropriate group.
During this process somehow the DB ownership gets messed up randomly either on primary or Secondary.
I can handle the primary server ownership mess-up by adding piece of code to set the ownership in the end, but for secondary I can't change the ownership as the DB is in readonly mode, resulting, when failover happens the application fails to open default DB.
Any lead on the solution would be appreciated.
Thanks,
Viral Shah
I am trying to build a nightly refresh process for SQL Server DB from on premise to Azure Cloud (IAAS). The Azure infrastructure is configured as 2 node always on. Every Day a new DB get created with retention period of 7 days. (Another script which deletes old DB)
Nightly Build Process as Below:
1)DB Backup get copied to Azure Blob Storage
2)Restore DB on primary Server on Azure
3)Change DB owner to appropriate login on primary Server
4)Backup DB/Log from primary Server and restore it on Secondary Server.
5)Add DB to alwayson temp Group.
6)Failover temp Group and change DB owner to appropriate login. (Application Dependency to have login ID as the owner of the DB).
7)Failback and remove DB from temp group and add it to appropriate group.
During this process somehow the DB ownership gets messed up randomly either on primary or Secondary.
I can handle the primary server ownership mess-up by adding piece of code to set the ownership in the end, but for secondary I can't change the ownership as the DB is in readonly mode, resulting, when failover happens the application fails to open default DB.
Any lead on the solution would be appreciated.
Thanks,
Viral Shah
Thanks - Viral