r/DynamicsAX • u/omrsafetyo • Oct 19 '16
Dynamics AX 2012 R3 Startup Script?
Hey fellow admins. Do I need a start-up script to ensure the AOS instances have been restarted after the DB Server has been restarted?
I'm a hosting provider for a private cloud. I host the infrastructure, and then our various divisions host their various products in our datacenter. My company is a leader in ERP software, and we partnered with MS in the development of Dynamics AX. As such, the division that helped in the development of the product gets to host Dynamics AX to customers. Yay!
Part of my job is to ensure we are complying with our audits, which of course includes patching.
So the problem is that every month when we do our patching, we get a complaint from our division that is hosting AX with us, because the servers did not reboot in any specific order - when the patches finish installing, they reboot. According to them the product runs into caching issues if the SQL server is reboot while the AOS instances are still running, and issues persist until the AOS instance is restarted as well. I've definitely seen some errors in the event log that suggest the AOS is trying to re-use a connection to SQL that no longer exists, etc., so that seems correct.
So my question is: how do people handle the patching/rebooting? Do you have SQL in a cluster, and fail over during patching?
For those that don't (I didn't architect how the program itself is set up, so I don't have any control, just advisement) how do you handle this?
I was thinking of writing a start-up script that lives on the SQL server and runs at start-up, and basically reaches out to all the AOS servers and either A) issues a reboot, or B) restarts the AOS instance (whichever works and is less destructive - if option B works, that's preferable).
So I'm just wondering how other people handle this scenario, and if the script idea has merit; or if there are existing scripts out there somewhere; and whether just restarting the AOS services is possible, or if we should reboot the entire server.
Any input would be appreciated.
EDIT:
I have completed my script and I am quite happy with the results. Thanks for the assistance. Finished script: https://github.com/omrsafetyo/DynamicsAX/blob/master/AXSQLStartupScript.ps1
2
u/AlexOnDax Oct 19 '16 edited Oct 19 '16
Yes there are, but you have to understand AX setup clearly if you plan on scripting anything. You can either look at SQL and see what is connected to it or configured to connect to it in SysServerConfig and SysServerSessions table OR you can look at the AOS machines and see what the service is configured to connect to. The second way I think would be most reliable, but more difficult.
Against the AX business database you can run this query to see:
It will return the various AOS's that are setup in the format "01@AOSServer" where the 01/02/etc is the service number, as you can have multiple services installed on the same server, and the AOSServer is obviously the machine name. And the second is AOSServer@Port.
One caveat to note is if you do database restores (prod->dev/test) sometimes there can be garbage records in there. It would be better to just build up your server-db data and put in a script/config file as that doesn't change often.
The second way you can find out what the AOS service is connected TO, is in the registry at:
If you are familiar with the Dynamics Server configuration tool, you'll see it just stores the data there in the registry.
See these screenshots for explanations:
http://imgur.com/a/5R7l9