• About

Day 2 Day Dynamics

~ Experiences of a working AX developer

Day 2 Day Dynamics

Tag Archives: RegisterServices

Refresh-AXServices custom PowerShell function

23 Friday Oct 2015

Posted by John Hagler in Powershell

≈ 1 Comment

Tags

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.

RegisterServicesAlt

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.

ServicesReresh

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.

Follow Day 2 Day Dynamics on WordPress.com

Day 2 Day Dynamics

  • RSS - Posts
  • RSS - Comments

Follow me on Twitter

My Tweets

Recent Posts

  • Minimizing Database Calls
  • Push-AXModel custom PowerShell function
  • Clean-AXModel custom PowerShell function
  • Get-AXTFSCombinedXpo custom PowerShell Function
  • Refresh-AXAifPort custom PowerShell function

Archives

  • February 2016
  • December 2015
  • November 2015
  • October 2015
  • September 2015
  • August 2015
  • July 2015
  • June 2015
  • May 2015
  • April 2015
  • March 2015
  • February 2015

John Hagler

John Hagler

John Hagler

I am the Dynamics AX Technical Architect at Dealer.com. I have been working with AX since Sep. 2006, starting with Axapta 3.0. I have worked as both a VAR and an AX customer.

View Full Profile →

Blog at WordPress.com.

  • Follow Following
    • Day 2 Day Dynamics
    • Already have a WordPress.com account? Log in now.
    • Day 2 Day Dynamics
    • Customize
    • Follow Following
    • Sign up
    • Log in
    • Report this content
    • View site in Reader
    • Manage subscriptions
    • Collapse this bar
 

Loading Comments...