ARM Template – Deployment Error “[Subscription().SubscriptionId]” The request is invalid…

Error

Recently I authored some ARM stuff in Visual Studio and I had a need for getting the current subscription ID the template is being deployed to.  So there is a helper function you can call like this…

“subscriptionId”: “[subscription().subscriptionId]”

I used it in the template like this…

2

…but as soon I tried to deploy the template, I hit this error all the time…

“code”: “BadRequest”, “message”: “{\”Message\”:\”The request is invalid.\”,\”ModelState\”:{\”variable.properties.value\”:[\”Invalid JSON primitive: 328de222-1a51-458a-96be-6770259e84c0.\”]}}”

3

I am not sure why this happen, but I figured out a workaround. If I concatenate the entire subscription id, it would work like this…

1

I hope this saves you some headache!

OMS – Azure Scheduler Solution

Bildergebnis für Azure Scheduler logo

UPDATE 07.08.2017 21:51: I found a bug in the ARM template which made the dashboard not appearing. I fixed it just now, in case you deployed the solution, just redeploy it. Sorry for that hassle.

Currently I am doing some more OMS stuff and therefore I also took a deeper dive at building ARM templates to deploy an OMS solution. I was looking for a simple Azure service to gather data from, which I could ingest into OMS. My goal was, to have a use case, where I only need to provide the minimal parameters necessary and the rest should be done by the ARM template.

How does it work?

Well, basically there is Azure Automation which runs a PowerShell script on an hourly schedule to collect data from Azure Scheduler service. If there are any collections and jobs in Azure Scheduler it will ingest the data into OMS via API.

The OMS solution will contains the following views:

  • Jobs with errors
  • Status of the jobs
  • Jobs and how many times it has been executed
  • How many jobs a collection contains
  • Some useful queries

OMSAzureScheduler

How do I deploy it?
Go to my https://github.com/stefanrothnet/AzureScheduler

image

You need to provide the credentials to access Azure Scheduler service, these will be saved in the Azure Automation account. Make sure the credentials have permission to access the subscription you are accessing. In addition you need to provide a schedule link GUID. Because there is no function in ARM template to generate a GUID, we need manually to provide a GUID. This GUID is needed to link the Azure Automation schedule to the Azure Automation runbook. Use PowerShell cmdlet New-Guid to generate a GUID and paste it into to the settings.

image

The template does the following steps:

  • Creates a resource group
  • Creates an Azure Automation account
  • Deploys the PowerShell runbook / script to collect Azure Scheduler data
  • Creates an Azure Automation schedule to run the runbook to collect the data. It starts every one hour starting at deployment.
  • Creates an Azure Automation variables for OMS workspace and key
  • Creates an Azure Automation  variable for the current subscription id
  • Creates an Azure Automation credential with username and password
  • Updates the AzureRM.Profile and AzureRM.Scheduler modules
  • Installs the OMSIngestionsAPI module
  • Deploys an OMS workspace and installs the solution into the workspace

If you have tried to create such a solution before or any other ARM project, you know, there are many problems you will face.

So what is the current state of this solution?

  • All the necessary components are being deployed and are working (I tested it only in the West Europe Azure location!)
  • There are some parts with the OMS dashboard I need to update and adjust, but for the moment it works and offers a good demo case for an OMS solution.
  • Be aware, it is not a production ready product, it is made for learning and testing. I tested it only briefly and I am not an Azure Scheduler MVP 😉 .

If you encounter any problems or things that don’t appear the way they should, let me know. Have fun!

SCOM / OMS – MP University 2017 Recording

Sielct

Yes, Silect did it again! Few days ago Silect Software provided MP University 2017, an online event packed with sessions from well known names like Kevin Holman, Brian Wren and Aditya Goda from Microsoft, Marnix Wolf from Didacticum and Mike Sargent from Silect. What I like about this event is, that it is not marketing instead the sessions are packed with very deep content of MP authoring and as it seems to start touching OMS as well Smile. If you missed this event I encourage you to watch the recordings online on Youtube.

MP Authoring Basics and Silect MP Author

 

MP Authoring using Fragments

Continue reading

OMS – Custom Solution “SCOM Effective Configuration”

I had been very busy lately so this blog has been quite for few days, but now I would like to provide a custom OMS solution. My goal was to build a solution which shows you the effective configuration of a monitor or rule, based on a group of objects in SCOM. I created two parts, one is a PowerShell module to collect all the data from your SCOM management server and ingest it into your OMS workspace. For visualizing the data I created a OMS view which looks like this…

screenshot

How does it work? Great question, so let’s start with the data collection.

SendEffectiveConfiguration PowerShell Module

I published the module on PowerShell gallery, which you can find here.

The module supports the following parameters:

  • GroupDisplayName

This parameter accepts any existing group in SCOM, that contains objects. E.g. Windows Server 2012 Computer Group.

  • ManagementServer

Set your SCOM management server here.

  • CustomerID

CustomerID is the workspace id where you want to analyze your data.

  • SharedKey

SharedKey ist the primary key for the corresponding workspace.

So the command executed would look like this:

Send-EffectiveConfiguration -GroupDisplayName  “Windows Server 2012 Computer Group” -ManagementServer SCOM -CustomerId [WorkspaceID] -SharedKey [PrimaryKey] –verbose

Continue reading

OMS – Where Can I Find the Sealed OMS MPs / Intelligence Packs?

image

Sometimes you need to have the sealed version of management packs / intelligence packs which get’s downloaded from OMS. You might need them as reference in your custom management pack solutions or maybe just to explore it. You can find the management packs in your C:\Windows\Temp folder on your SCOM server.

image

As you can see the name of the files corresponds to the solutions in OMS.

I hope this quick tip saves you some time.

SMA – ISE Add-On Editing Runbooks

powershell-whatsnew

A couple of month ago Microsoft released the latest (updated) version of PowerShell 5.0 . Why is this worth writing about? Well, with every new release there are some fantastic goodies included, you just need to discover them :). One of these goodies is (my) long awaited runbook editing capability for ISE. In this post I would like to show you how to get it installed and how to work with it.

First we need to get the module which is called SMAAuthoringToolkit. Because my lab environment does not have internet access, I will just download the module to my notebook and copy it to the lab machine.

Save-Module  SMAAuthoringToolkit -Path C:\Temp

This command will save the module from the PowerShell Gallery in C:\Temp…

image

Next, I copy the module to the lab server to my user path C:\Users\[user]\Documents\WindowsPowerShell\Modules

image

Next type…

Install-SMAIseAddOn

This will install the add-on so that it will be automatically loaded next time you start your ISE.

If you have internet connection on your system you don’t need to do the above “offline” copy steps, instead you just need to type…

Install-Module SMAAuthoringToolkit -Scope CurrentUser

If you add the -Scope CurrentUser parameter, the module is installed to…

$env:USERPROFILE\Documents\WindowsPowerShell\Modules

Then, if you want the PowerShell ISE to always automatically load the add-on, run…

Install-SMAIseAddOn

Otherwise, whenever you want to load the add-on, just run the following in the PowerShell ISE…

Import-Module SMAAuthoringToolkit   

No let’s start ISE and see what we got…

Continue reading

Azure Automation – ISE Add-On Editing Runbooks

image

Well it has been a while since last post, because there is a lot going on in my private life as also in my job. But now some “tasks” are completed and I will have more time for community work again. Microsoft product machinery is running at high speed in all areas. One tool I really appreciate is the ISE add-On for Azure Automation. I have written quite a lot of runbooks in the past for SMA using regular ISE and Visual Studio but a tool for writing runbooks which integrates into the SMA environment is missing. This add-On integrates seamlessly into your ISE environment and lets you write runbooks for Azure Automation in different flavors like regular PowerShell scripts and PowerShell workflows and executes them using Azure Automation. As a target you are able to choose either Azure itself or a Hybrid Worker Group. Joe Levy (PM Azure Automation) has already written a post about this add-on. I would like to dive a bit more into this.

How does it look like?

As you can see it seamlessly integrates into ISE…

image

Continue reading