How I saved thousands of dollars on my Azure environments!

I just love such headlines, because it instantly attracts attention.

But in this case it is actually true. And Microsoft is even wants us to do this. I want to write how to automatically shut down and start up environments in Azure, so that you are not spending more than needed. This post is for newbies, and experts surely will bombard the comment section with improved suggestions on how to make it even better.

In this example I have 4 environment running in Azure and the machine type I prefer is the D13_v2. This will cost me 3696 USD per month if I just let them stay on for 744 hours per month.

But I only plan to use them 07:00 à 17:00 Monday to Friday. This is 200 hours per month, and then it will just cost 993 USD J A lot of fun can be done with these extra credits.

So what is the next step? The trick is to use the Azure Powershell Runbook. Here is the step-by-step instruction on how to set it up:

1. Log into Azure, and open the Azure automation

2. Add an Automation Account.
    Create a name, like “TurnOffOnVM”.
    Select the subscription, and if a resource group should be created. Also if you want an Azure Run As Account. (I didn’t bother to have that, since I have no important stuff on these environments)

3. Then create an Asset named “automation” for holding credentials, that will run the shutdown/start up scripts. The credentials you are using must have the rights to run scripts and to start/stop VM’s.

4. Let’s create 2 Runbooks, that holds the scripts and schedules for the start and stop scripts.

5. Use the “Powershell Workflow” type

 

6. Let’s put in the “Start script”. It’s done here

 

I have removed my VM-names in this example.

If you wonder what your VM name is, it is the computer name, that can be seen here:

Here is a copy-paste version of the Start-up script:

workflow StartVM

{

    $cred = get-automationpscredential -name “automation”

    add-azureaccount -credential $cred

    select-azuresubscription -subscriptionname “Microsoft Azure Enterprise”

 

    $VMs = Get-AzureVM

 

foreach($VM in $VMs)

{

if ($VM.Name -In “VMName1”, “VMName2”, “VMName3”, “VMName4” )

{

if ($VM.PowerState -ne “Started”)

        {

     Start-AzureVM -Name $VM.Name -ServiceName $VM.ServiceName -ErrorAction Continue

        }

}

}

}

7. Let’s put in the “Stop script”. It is basically the same procedure as creating the “start script”, so I just add the copy-past version of the script.

workflow StopVM

{

    $cred = get-automationpscredential -name “automation”

    add-azureaccount -credential $cred

    select-azuresubscription -subscriptionname “Microsoft Azure Enterprise”

 

    $VMs = Get-AzureVM

 

    foreach($VM in $VMs)

    {

    if ($VM.Name -In “VMName1”, “VMName2”, “VMName3”, “VMName4” )

    {

        if($vm.Status -eq ‘ReadyRole’)

        {

        Stop-AzureVm -Name $vm.Name -ServiceName $vm.ServiceName -Force

        }

 

    }

    }

}

 

Remember to press the “publish” button the scripts J

8. Let’s create a schedule (one for the Start runbook, and one for the stop runbook)


9. You can now monitor the start/stop scripts:

 

10. Go party with all the credits you have saved! And if you see me, and use this script, buy me a beer J

 

Happy DAX’ing J

The most important AX.HELP page

To always keep an eye on what’s happening is important. We see that AX.HELP is growing and becoming the number one center for understanding the new AX. I want to give you the most important page; https://ax.help.dynamics.com/en/wiki/help-get-started/ Read it!

What I did was to setup a RSS feed to get all the news and new articles, and the address is https://ax.help.dynamics.com/en/revisions/

Setting this up in Outlook is easy. Right-click on the RSS Subscription, and add https://ax.help.dynamics.com/en/revisions/

You will then get a RSS message for each new post and article. You will in 5 minutes every day get the overview of what have been published and update. No more slow searching, and you will quickly be the “go-to” expert, that knows it all.

Happy DAX’ing

 

 

 

New Dynamics AX – Pimp up your form-letters with document branding

The New Dynamics AX never stops to surprise me, and every day I find new possibilities and solutions. Microsoft have made available a new set of form letters, like purchase order, sales confirmation, invoice etc, and installing them is optional. What is new is that they are much nice and modern, but they are missing country specific requirements. Microsoft is calling them “Modern reports”, and you can read about them here.

But the main topic of this blog is about how to pimp-up your form letters, with document branding. The following report is the Purchase order in modern design, and where I have added a logo and some colors.

The menu item for controlling this is found under Organization à Setup à Document branding

We have the following menu items;

Document brands, is just the identifier, like company ID etc.

Document images is a container for logoes etc,

The Brand details is where we can override per formletter and design, and select colors, and override addresses and contact information.


 

I expect Microsoft have much more coming, so stay tuned J

AX RTW My ODATA and JSON journey – Part III

Now the fun begins, and let’s develop! The following post is only meant for hardcore Dynamics AX technical consultants J

In previous posts I wrote about how to access Dynamics AX data and metadata through ODATA and only using an internet Explorer. In these scenario’s we where only fetching data from Dynamics AX. This time, we will use Visual Studio to publish data into Dynamics AX, by accessing the ODATA services. I must let you know, that I consider myself as a newbie to creating C# code, and the following post is only for giving you a directional guide for you to start exploring for yourself.

What you need to make this happen is:

  1. Visual Studio 2015
  2. Administrator access to Azure AD
  3. A deployed New AX on Azure

What I wanted to achieve here, is to be able to add vendors from a C# program. A None-Dynamics AX developer may have no idea of the inner structure of AX, but they can be given access to the metadata. Based on this metadata it should be possible to create CRUD integrations. One issue with Visual Studio is that it is not possible to consume ODATA services directly. So we need to generate a proxy library. The MSDN OData v4 Client Code Generator is the best way of doing this, because it will generate wrapper classes for the data entities. To speed up a bit I found the AX-LAB12, where Microsoft is showing how to import a BOM, here I found the framework that we can use. This AX-LAB12 contains a word document that is good to understanding how to set this up. I’m “stealing” the following 4 first classes from the.

The AuthenticationUtility is the class that makes sure we are authenticated with Azure AD, and that we are logged in with the right user. In this class you can hardcode the user/password and the Tendant and the ActiveDirectoryClientAppId

The next step is to generate the ODataProxy. This is done in the Microsoft.Dynamics.DataEntities project. This basically means creating a bunch of classes that reflects all the metadata. It will give us a class, so that we can assign values to Odata fields and execute methods etc. But first we must specify where all the metadata can be downloaded from. In the picture below, you see that this is just a hardcoded string in the OdataProxyGenerator.tt file.

Then right-click as shown under, and select the “Run Custom Tool”.

This will then download all the metadata from the published data entities in Dynamics AX, and create one class per data entity. It takes a few minutes, and it creates thousands of classes.

Since we want to create vendors, it is interesting to see how the Vendor data entity looks in AX, and how the generated C# proxy class looks like:

As you see, we are consuming the ODATA Data entities into visual studio, that let’s to access fields and methods as we are used to in X++. And this by only generating proxy classes from the Odata metadata.

Then I may start developing against the ODATA proxy classes, and now I see that fields and method lookup, that we are used to in X++ is working. As seen in the following picture, I’m declaring the vendVendorEntity of the type Vendor, that have the same structure as defined in the Data Entity.

My complete code for creating a vendor using ODATA is therefore :

I build and run:

I then check AX to see if the vendor is created:

It works J

Let’s try to see if I change the code, and are selecting a vendor group that does not exists :

It correctly don’t let me create the vendor J

The conclusion:

The ability to create CRUD operations using ODATA, changes the game. External none-Dynamics developers can create apps and integrations through the Odata services, and it regulated through security and validation. They don’t need to know the internal structure of Dynamics, because this is exposed through the metadata service. Dynamics AX is truly a game changer.

Happy DAX’ing J

 

 

New Dynamics AX and the Excel Add-on

When using the «Open in Excel»( Dynamics Office Add-in) feature in the New Dynamics AX RTW, you may have some trouble opening it in Excel.

Especially if you have a corporate login, like me. It then seams that the login failed.

 

Microsoft have upgraded the Dynamics Office Add-in, but on existing demo data (Contoso) may also need to be changed.

Then the connector seams to be working (At least for me)

Also take a look at https://ax.help.dynamics.com/en/wiki/office-integration-troubleshooting/

Happy DAX’ing

New Dynamics AX On premise = Azure Stack

As we know, deploying the new Dynamics AX will basically come in 3 different flavors. I wanted to explain a bit what this means and what I have found. The information here should be double checked together with your partners, and also with Microsoft. Also remember that it all is very fresh technology, and that things may change quickly as must is in early releases and preview.

 

  1. AX Public cloud – Black-box, maintained by Microsoft in Azure and it just works.
    The public cloud “edition” was the first platform that the new Dynamics AX was released on. In the public cloud it is Microsoft personnel that is deploying and monitoring the instances. Customers and partners should have no technical access to the production environments. Data and code (like customizations) are created as packages and uploaded into LCS, where according to maintenance windows, and Microsoft will deploy them to the production environment. Customers pays a monthly fee per user, that includes licenses a production environment with high availability, disaster recovery and some sand-box environments (for testing and dev). The customer doesn’t have consider how to scale or what kind of virtual machines is needed. This is taken care of by Microsoft. Customers must expect to pay at least 110.000 USD per year in costs for this. It is my consideration that this offer actually is a very good offer, because it includes many of the services and licenses that we don’t normally consider when evaluating costs for operating a ERP system. I think than smaller customers (50-250 users) would benefit from this scenario.
  2. AX Private cloud – Maintained and deployed by customer/partner, but still on Azure.
    Private cloud is 100% running in Azure. Private just means that Microsoft is not deploying and monitoring the instances. In this scenario you will purchase AX licenses, and you will purchase Azure services and deployments. Basically 2-3 invoices J. You scale up the VM’s according to you needs, and it is your own responsibility. It is typical a partner that can help out, and you probably will have to purchase service agreements to monitor and maintain your Azure deployed instances. Will this be cheaper than the “public cloud” offer? If you compare apples with apples I don’t think so. There are many hidden costs, and if you sum up the costs, at least my internal calculations show that this offer quickly can be 20% more expensive than the Public Cloud offer. But the private cloud offers flexibility, but will demand a very knowledgeable technical department/partner. You can decide more by yourself within the boundaries of the Azure. I expect that larger customers (250+ users) would like to go for this scenario.
  3. AX On-Premise and Azure Stack – For those that have a datacenter to spare

    Azure Stack is the new hybrid cloud platform product that enables organization to deliver Azure services from their own datacenters. You get cloud services, yet maintain control. You decide where to keep your data and applications—in your own datacenter or on others/azure. You will still pay for the AX licenses, but the you will also have to pay for your own hardware. There is one problem. It is not released yet. We are waiting for Windows Server 2016 with Azure Stack, and SQL Server 2016. These are still in technical preview. But for those (like me) that like to try out, you can actually download it from https://azure.microsoft.com/en-us/overview/azure-stack/ . If you wonder what kind of machinery is needed, take a look her. (Basically 16 Cores , >128 Gb RAM and a few TB of disk). It will be a bit difficult to run the Azure Stack on my portable PC J. Also remember that there will still be lots of services that still have to be on the cloud. I assume that this option will be selected for large enterprises (1000+ users) and for hosting providers/ASP.

And remember that what I write here is not facts, but just my interpretation of how it can be.

Happy DAX’ing J

Mobile Access for Visual Studio

In the new AX the tool we use for work, development, test and build is Visual Studio Online(VSO). Now a mobile access to VSO is available in the Visual Studio Markedplace. It enables you to browse, monitor and engage in projects via your phone, It’s still in preview, but it looks very interesting.

Take a look at it here; https://marketplace.visualstudio.com/items?itemName=sprints-for-vsts.sprints-for-visualstudio