AIF, Application Integration Framework, Automation, AutoRun, AX, AX 2012, AX Services, PowerShell, R2 CU7, RegisterServices
Now that we have a working build, I’m going to be focusing on the functions that I use to manage my environment and code pushes. I will be releasing these functions as both stand-alone functions and to the D2DDynamics module. You can integrate them into your environment either way.
The Refresh-AXServices custom PowerShell function allows you to automate service refresh functionality in AX. This function looks just like all of the other functions that use Start-AXAutoRun. It is a template you will see over and over again.
The process it is automating is navigating to the Services node in the AOT, expanding the node and then right clicking on a service and choosing Add-ins -> Register services.
This process opens an AIF Services form that allows you to see information regarding your AX service classes. It also has a button to allow you to refresh your services when there are code changes. This is the process that is automated.
The Refresh-AXServices function takes between 1 and 7 parameters:
- ConfigPath (Client configuration for the chosen AX environment)
- LogFile (The value defaults to the temp folder but can be overridden if desired)
- TimeOut (The value defaults to 30 minutes but can be overridden if desired)
- SMTPServer (SMTP server to use to send the email)
- MailMsg (Net.Mail.MailMessage object used to send the email)
- AXVersion (The AX version. It defaults to 6.)
- VariablePath (Path to a file used to default the parameters/variables)
I use the VariablePath parameter the same way that I do in the other functions I’ve posted that use it. This function can be found in Codeplex. The steps of this function are:
- Load the variables if a VariablePath parameter is used
- Get the AX environment info using Get-AXConfig
- Get the AIFServiceGenerationManager::registerServices AutoRun xml using the Get-AXAutoRunXML function
- Call the Start-AXAutoRun function to refresh the services
This function uses the ability that the AutoRun process has of calling static methods in AX. While this particular function is being used to call the AIFServiceGenerationManager::registerServices() static method, AutoRun allows you to call any static method inside of AX. If you get really creative with it, you can build your own static methods inside of custom classes to automate non-static method processes inside of AX. The AutoRun functionality is very powerful and can probably be used to automate just about any process inside of AX.
This function should also only be run on the AOS server. It has been tested using AX 2012 R2 CU7 but will probably work for other versions.
Pingback: Push-AXModel custom PowerShell function | Day 2 Day Dynamics