INSIGHT AX CONSULTING
Dynamics 365 Finance & Operations (AX) consulting, support and integration solutions
We recently came across an issue where we needed to restore our cloud hosted D365 tier one development environment. There are similar questions in the community forums however with no much details so we think it will be useful to put together a small instruction here.
Assuming version control is used, database back-ups are available and you are an admin on the box, it’s quite easy to do by doing the following:
Also, new VM can be provisioned all together in LCS but this is not always a good option, so let’s look how to repair existing one.
In order to restore content of the PackagesLocalDirectory you need either have a previously created backup or use clean packages from standard VM (without any customizations) plus run a synchronization of code from your version control (VSTS). Let’s look at the second option because first one is easy and its part of that anyway.
Clean packages can be taken from build agent definition, so if there is at least one build box in your LCS project it should have folder like J:\DynamicsBackup\Packages which contains exactly what we need. Pack it into archive and move into your broken environment. Unpack into one of the drives, we used J:\MSSQL_BACKUP. When ready stop D365 services, IIS and reporting services and close visual studio. Start CMD as admin, delete contents of AosService\PackagesLocalDirectory and run the following robocopy command:
robocopy J:\ MSSQL_BACKUP\package K:\AosService\PackagesLocalDirectory /MIR /MT:32
next, need to unlock the files which can be done by running PowerShell with following command:
dir -Path K:\AosService\PackagesLocalDirectory\ -Recurse | Unblock-File
Restore Database from back-up using SQL Management studio.
Open visual studio, re-map local directory (if needed) to your VSTS branch and synchronize code customizations.
Restart IIS. Refresh models in Visual Studio (may need to restart VS) and run a full application build.
PS. Check on the file K:\AosService\PackagesLocalDirectory\Bin\DynamicsDevConfig.xml for correct reference to the database as it may need to be updated in order to run ‘update cross-references’.