Friday, July 20, 2012

Deploying Customizations between AX 2012 Environments



Hi there!

I hope everyone is having a good week and that you are ready for another article about AX. In this post, I would like to focus on deployment strategies in AX 2012. I have been getting lots of emails with questions about deploying customizations between two Microsoft Dynamics AX 2012 environments. There is a good reason for this as many people seem confused about the model store file, and how can it be used to move metadata between two AX 2012 environments.

In this post I would like to recommend moving customizations by exporting the entire model store file between AX 2012 environments.

To start, I would like to share some definitions that we are going to be using in this post (source: www.microsoft.com)

Application Layer: A single layer of AX 2012 application that exists within a model store (NOTE: The elements in higher layers will override elements in lower layers)

Model Store: A collection of tables in the AX 2012 database that contains the application metadata. (NOTE: The model store can be compared to the AOD file share in AX 2009)

Metadata: Information about the properties or structure of data in the Application Object Tree (AOT) that is not part of the data values. (NOTE: Everything element that exists in the AOT is considered metadata)

Model store file (.axmodelstore): A complete model store that has been exported from the database. The file includes all metadata, compiled artifacts, CIL code, and security artifacts. The file is used for moving consistent metadata between environments with minimum downtime.

Model file (.axmodel): This is a model that has been exported from a model store. (NOTE: This file is the main vehicle of metadata deployment in AX 2012)

Moving right along , when deploying metadata between AX 2012 environments, we can do it using a number of different methods that range from importing/exporting XPO files to moving a whole model store file at once.

The following table shows a comparison between these methods (source: www.microsoft.com)



XPO Files
Model Files
Model Store Files
Imported/exported by using…
MorphX

AXUtil.exe or Windows PowerShell cmdlets
AXUtil.exe or Windows PowerShell cmdlets
Can be uninstalled?
No
Yes
No
Can be signed?
No
Yes
No
Microsoft Dynamics AX Object IDs from source environment preserved?
No



No



Yes



Compile required?
Yes
Yes
No
IL Generation required?
Yes

Yes

No


This might vary from project to project, but I believe that we should adopt a single and concise method that we can apply in our projects to quantify the results over a period of time, and to minimize downtime.

In addition, I think that a crucial step to achieve a consistent deployment methodology is to understand that the environments we are moving data from/to need to have the same metadata structure. For example, in the last six months I have learned that if a customer already has a production AX 2012 instance running, the Test and Staging environments can and should be a replica of it to avoid conflicts on ID’s and model store metadata.

We also need to ensure that any customizations we do, must first be applied to the source environment, then have them thoroughly tested, and then move them to the production environment via our preferable method. Otherwise, we open the door to inconsistency between environments.


So, let’s take a look at how the deployment process should be (source: www.microsoft.com)



Microsoft has outlined a list of common mistakes that arise when importing a single model into a production environment.

1-We start with a customization that we want to move into the target environment.





2-Then we import the model that contains our customizations. Because this is a new object that does not exist in the target system (Stage/Production), AX might give the object an ID that is different from the ID in the source system.





3-Then, someone uses he system and adds transaction records that reference the AXID.





4-Let’s say that the next day we make another customization and want to deploy the entire model store for minimal downtime (which was a different approach from step 2). To do this, we export the entire model store, which includes the IDs.




As you can see, this inconsistency will create conflicts because the ID’s as the two instances have different ID's.

Now, the idea is to choose one methodology and stick with it. However, Microsoft suggests importing the entire model store file from the beginning, so we don’t run into ID conflicts in future deployments. It is essential that the target database (especially in a production environment) is initialized from an exported source database and not individual model files.

The following sequence shows the correct way to move customizations between environments to avoid conflicts.

1-We start by creating a blank AX DB by using Setup. (This will contain the Foundation SYS model).





2-We initialize the model store by importing the model store file from the source to the target system.




3-When this happens, we can start adding data to the target system, and at the same time, customizations can be made to the source system.




4-Now, when we are ready to re-deploy new customizations, the entire model store is once again exported to minimize system downtime and to avoid ID’s conflicts.




In conclusion, every implementation should include several separate environments to consistently control what code ends up running on the customer’s production system. There are many methodologies available to us, but some of these can create ID’s conflicts when the system assigns ID’s. To avoid this problem, we should move customizations between environments using the model store file.

That’s all for now, and I hope that this posts clarifies some of the doubts about deploying customizations between environments in AX 2012.

Also, keep checking my blog as I will post a very interesting article on how to setup Items for AX 2012 Retail.


Tuesday, July 17, 2012

Microsoft Dynamics AX Retail 2012 - Blank Operations



Hi There,

I hope everybody had a restful weekend and that you are ready for another creative and challenging Microsoft Dynamic AX week.

On this post I would like to take a look at how the Blank Operations work in Microsoft Dynamics AX 2012 Retail. Please note that there is a lot to cover under this topic, and I hope that what I’m covering here today can help you get started on creating your own customizations for AX 2012 POS in no time.

So, what are Blank Operations? Well, Blank Operations, in my opinion, are the fastest and easiest way to extend the AX for Retail POS application. In addition, Blank Operations can be assigned to a button action right in the Retail POS till layout, and the great thing about them is that we can deploy as many of them as we need, which makes Blank Operations very flexible.

When we create a new project in Visual Studio and use the Blank Operations namespace, we are actually overwriting an existing DLL that exists within the AX 2012 POS application folder (located in C:\Program Files (86)\Microsoft Dynamics AX\60\Retail POS\Services).



Within this DLL we can write simple and/or complex logic to achieve different business requirements. Further,  one of the greatest advantages of Blank Operations is that they don’t really touch the core AX 2012 Retail POS logic and therefore they are safe to play around with and extremely easy to deploy.

So let’s start by creating a new Project in Visual Studio and then let’s create a form that then we will hook up to a Blank Operation in our Retail POS till layout.


1-Create a new project in Visual Studio and call it BlankOperations. By default, the namespace will be BlankOperations as well.

In here add the following code:


  

2-Add the following references to your project by right clicking your References folder. (For more information on how to do this please AX 2012 POS Development - Application Triggers)




3-Set your project’s properties to build the dll into the desired folder (C:\Program Files (86)\Microsoft Dynamics AX\60\Retail POS\Services – for more information please see AX 2012 POS Development - Application Triggers)

4-Now let’s create another new project (class library), call it MyForms, and then add a form to it, and call it MyBlankOperation. You will have to set the build properties for this project the same way you did it on the previous step. However, just set the path to C:\Program Files (86)\Microsoft Dynamics AX\60\Retail POS so the MyForm project dll will exist in the root of the AX Retail POS.





Add a label to the form and build the solution.

 




5-Build the solution

6-Go to your BlankOperations project and right click references and browse to C:\Program Files (86)\Microsoft Dynamics AX\60\Retail POS and look for the MyForm.dll. Then add the reference to your code (i.e. using MyForm;)

7-Open your AX 2012 POS Retail and on the edge of the screen right-click and choose “Customize Layout



8-From the designer (hidden items) drag a button to a place in the till layout.



9-Choose whether or not you want to save the changes (If you just want to test it, you can say no and the next time you open the layout it would be stay as the original one)



10-Right-Click on the area you just created and choose New Button Grid



11-Fill out the necessary information as per the picture below and when you are done click Confirm.



12-Right-Click  on the area you just created and choose Open Button Grid



13-From the dialog box click the Button Grid drop down list and choose BlankOp, which is the name we gave to our button in step 10.



14-From the Action pane click the Item drop down list and choose Blank Operation. Then fill the information as per the picture below.



15-Now you should have a button in your till layout. Click it and you’ll see the form we created before in this tutorial.



Note that you can have many buttons with different ids that can be manipulated later in your code by an operation ID. As you can see, Blank Operations are easy to implement and deploy, and most importantly they can help you create your own custom logic without affecting the AX 2012 POS core logic, which is nice.

Well folks, this is all for now and I hope this can help you get started on Blank Operations.

Also, keep reading my blog as I will be posting and overview of the deployment process in AX 2012 and much more in the coming days.


Tuesday, July 3, 2012

Tutorials for SQL Server 2012



Hi there!

I hope everyone is doing great this week and getting ready for the 4th of July that reminds us of our nation's birthday.

On another note, today I would like to share with you a few tutorials for SQL Server 2012 new features and solutions. With the release of Microsoft Dynamics AX 2012, it is clear that there is a greater demand for this knowledge as SQL Server 2012 is more and more being adopted by many business out there like never before.

The following is the list of four tutorial which has been created for SQL Server 2012 by Microsoft.



Tabular Modeling
In this tutorial you can learn how to create a SQL Server 2012 Analysis Services tabular model that could empower a sales and marketing team to analyze on-line sales data.

Multidimensional Modeling
In this tutorial you can learn how to develop and deploy an Analysis Services project that enables individuals to analyze many angles of their business.

Create a Sample Report With Power View
In this tutorial you can learn how to utilize the Power Views to create a simple report. These tools are extremely visual and can help individuals get the information they look for in seconds.

Just keep in mind that to go through these tutorials you will need to install the AdventureWorks sample database. You can get it from Sql Authority Here

That's all for now and keep checking my blog for much more to come.