2015. május 15., péntek

Set-AzureAutomationSchedule is bugged - "The start time of the schedule must be at least 5 minutes"...

We host our development servers in the cloud, and to save serious  bucks, they only run during office hours (50 hours a week out of the the 168, thats a nifty 70% saving).

There are two azure automation tasks, one shuts down the computers every evening, and another starts them up half an hour before anyone gets to the office.

However, overtime happens, so there is also a script that each developer can run that delays the evening shutdown with a couple of hours. This basicly disabled the evening shutdown Automation Schedule, and the morning startup script turns it back on.

This is the theory.

In practice, Set-AzureAutomationSchedule is a piece of crap and doesn't work half the time. When I try to set the status of a perfectly valid schedule, I encounter the following error message;



Mind you, the script works on the first day when you create the schedule, only later does it stop working.

The workaround is simple; instead of enabling and disabling the schedule, I simply drop and recreate it.

2015. április 20., hétfő

Turning on tracing in CRM 2013 with a single powershell command

The following  command turns on tracing in CRM 2013. The directory is automatically created during CRM setup, you don't have to create it yourself.


2015. március 25., szerda

Opening a password protected Excel document from c#

I have to write a migration tool for a client whose idea of data security is password protecting the Excel files.

However even if I supplied the Password and WriteResPassword parameters to the Open function, it still gave me a little dialog box asking for a password.

With some trial and error I found that in Read-Only mode the interop will actually open the file silently, so I thought I would share the code snippet.

As usual, your mileage may vary.

2015. március 11., szerda

Things to do before uploading a VHD to Azure

I recently had to upload several virtual machines into azure. No sysprep, no image creation, just moving a domain consisting of a couple of virtual servers and a DC into the cloud.

After uploading the disks, creating a virtual network, creating virtual machines etc I got the following super annoying message.

Remote Desktop can’t connect to the remote computer for one of these reasons:1) Remote access to the server is not enabled 2) The remote computer is turned off 3) The remote computer is not available on the network
Neither restarting, nor recreating the machines, nor resizing the machines, nor deleting the RDP endpoint and recreating it helped (if you encounter the same error try these steps nevertheless)
After a bit of trial and error I created the following checklist for future endeavours, maybe it will help you as well. 
  1. Enable Remoting in System/Remote settings (well duh)
  2. Open incoming TCP on port 3389 in the firewall for all network profiles. (Or just turn the whole windows firewall off, Azure doesn't allow any incoming traffic anyway)
  3. Install Azure VM Agent (from here for example). It seems like if you don't do this you will be stuck on the "Installing VM extensions" step of creating the virtual machine
My experience had been that I could only log in after the Installing VM Extensions step completed.

2015. január 28., szerda

The proper way to install AX 2012 RTM on Windows 2012

When installing AX RTM on Windows 2012 the prerequisite validation tool gets stuck on KB2390372, an update that you cannot possible install on Windows 2012. It gives a weird error message, "KB2390372v2 does not apply, or is blocked by another condition on your computer."



In theory CU5 solves this issue, but how can you install CU5, before installing RTM?

I have found contradictory information on the net, so I thought I would share with you guys what worked for me. Not sure if all the steps are neccessary, but..

  1. Install the web server and the app server roles, make sure to include .NET and Identity foundation (not sure if this is n
  2. Start the AX RTM setup
  3. Install the setup support files, and configure most of the prerequisities
  4. Download the CU5. 
  5. Unpack CU5
  6. Start installing CU5, tell it to patch the setup support files
  7. Start AX RTM setup again
  8. You DO NOT have to copy the CU5 files under the Updates folder of your AX install folder. This is a false piece of information (or at least it was not neccessary for me... but you know... it's AX. Your mileage may vary)
  9. Just continue as usual, it should not ask for KB2390372 anymore

2014. december 18., csütörtök

LedgertransStatementDP.ProcessOffSetAccountInStaging has a copy-paste error

I found a bug in AX today in the data provider class of the Ledger trans statement report, and I will share it here, in case it helps anyone.


The task: lets fill the fields (OffsetAcct1, OffsetAcct2, and OffsetAcct3) with some data.
What happens: the code fills OffsetAcct1, OffsetAcct2 and for good measure fills OffsetAcct2 again, never using OffsetAcct3 despite the intention obvious from the comments.

The whole function is a nasty mess of a way of solving the task, but at least it doesn't even work.
Here is the original code snippet;

And here is my no- so-complicated fix for the offending paragraph



2014. szeptember 12., péntek

Show all fields: Property name has max length 40

I spent some time today with the following error:
The user right-clicked an Advance Invoice record, then chose "Record Info", then "Show all fields" and got the tasty error message below:

Property Name has max length 40. An attempt to set it to a string having length 41 has been made.

You would get similar error messages, if you called the same function on the Advance invoice lines, though then it would say length 45.

The solutions: the SysRecordInfo Form on the SYP layer contains a bug.

The problem is with the line marked with red (duh).



The Form's name can be only 40 characters long. The DictTable.name() is "CzCustAdvanceInvoiceTable" (25 chars) + _ShowAllRecords_(15 chars) is too long. Tough luck.

I don't know which KB article dropped the ball on this one, but it's okay in SYS layer, and wrong in SYP layer.

I took the easy way out and simply removed the '_ShowAllRecords_' from the function call, and presto!, it worked.