Tuesday, May 16, 2017

Missing solutions in Azure OMS

I wanted to install the Service Map solution in my Azure OMS development workspace. But I couldn’t find it. Anywhere. It wasn’t in the Solutions Gallery. But I couldn’t think how else you would get it.

The documentation wasn’t helpful. The documentation assumes you already have it. It doesn’t explain how to get it. Google searches were fruitless.

With the help of Sam Cogan, Microsoft MVP, I finally figured it out.

Not all OMS solutions have been rolled out to all regions. If your OMS workspace is in a region which doesn’t have a particular solution available, it is just missing from the Solutions Gallery. And most annoying, there is no one region with all possible solutions.

In the Americas, most Azure services are rolled out to West US first. OMS is one of the exceptions. OMS services are rolled out to East US first. Mostly.

My OMS workspace was located in West Central US. As of this writing, Service Map and several other solutions are only available in East US, so I couldn’t see them.

I created a second OMS workspace in East US, opened the Solutions Gallery, and all of the “missing” solutions were there.

It is always easy to find things when you know where to look.

Saturday, May 13, 2017

Self-referencing formula in PowerShell

A formula in PowerShell can have a reference to another part of the same formula.

I saw a script that calculated a start time at the next quarter hour from the current time. The code used was cumbersome, so I naturally felt challenged to do better.

My first attempt was to do this. We get the current datetime with the seconds and milliseconds chopped off. (Normally I always use full parameter names, but I may make an exception here to declutter the code. I haven’t decided yet.) Then we add 15 minutes minus the current minutes modulus (remainder) 15.

$Date = Get-Date -S 0 -Mil 0
$Start = $Date.AddMinutes( 15 - $Date.Minute % 15 )

Not bad. But can we do it in one line? And not just a one-liner for the sake of a one-liner. That would be stupid and useless. We’re not willing to sacrifice readability here. Clarity is important. Can we do it elegantly in on line? Yes. we can.

One way is to use a pipeline to first create the date, which we can then reference twice in the ForEach scriptblock.

$Start = Get-Date -S 0 -Mil 0 | ForEach { $_.AddMinutes( 15 - $_.Minute % 15 ) }

Not a bad solution, but I like to avoid pipelines when they aren’t strictly necessary, and creating a pipeline to handle a single object instead of a collection would seem to fit the definition of an unnecessary pipeline.

There is another way.

If the setting of a variable is wrapped in parenthesis, the value of the variable is set, and then the value is returned.

This just sets the $Date.

$Date = Get-Date -S 0 -Mil 0

But this sets the $Date and returns the new value of $Date.

$Date = Get-Date -S 0 -Mil 0 )

So now we can do things to the returned value, and reference the value of $Date in the process. Like this:

$Start = ( $Date = Get-Date -S 0 -Mil 0 ).AddMinutes( 15 - $Date.Minute % 15 )



Wednesday, May 10, 2017

Azure Cloud Shell Preview

Azure Cloud Shell Preview was rolled out today. A coworker, Joe Behrens, noticed the new button in the toolbar in the upper right of the Azure portal.


Cool! we thought. Another place to do PowerShell. Or…wait. What?



Microsoft’s new browser based shell for managing Azure resources is BASH.

Wow. This IS the new Microsoft.

Don’t worry, though. PowerShell is “coming soon.”



Wow.