I have a script that does a number of things. One of these is to restore a DB. The script gets executed during ARM Template deployment, it works perfectly but the deployment takes ages while waiting for the DB to restore and eventually times out.
So I thought I would place the DB restore in a Start-Job script block so that the DB would continue restoring in the background and the job would complete successfully. When running this is my session it works as expected, but during the deployment, it doesn’t work. I’m not really sure why, but I assume it’s because the script is executed under the system account and maybe doesn’t work this way?
So I’m after some advice about what can be done, maybe a better way of executing the script, maybe a way to initial the DB restore but maybe throw a custom output? Once the DB restore is executed the DB will run in the background regardless of the PowerShell session running.
Many thanks in advance