I would like to open an Azure Monitor workbook using parameters passed in the url. For example, to open the workbook named WorkBook1
and passing in Parameter1
with Value1
and Parameter2
with Value2
, I would expect to be able to do something like this:
https://portal.azure.com/.../workbook/WorkbookTemplateName/WorkBook1?Parameter1=Value1&Parameter2=Value2
This feature doesn't appear to be documented anywhere but it seems like it should exist. Is it possible to pass a workbook parameter in the url to an Azure Monitor Notebook?
It isn't documented because it really depends on the Azure Portal's implementation of URLs, which is complicated, to put it simply. (i don't want to hide behind the org chart here, but the history of how deep links work in the azure portal is a long and complicated story, as with any huge software project π)
That being said, it is complicated and i'll look at getting better documentation about this shipped publicly (probably fastest in our GitHub Docs, which eventually gets to our Azure Docs), and i'll make it as simple as possible here...
The easiest way to start is to open the thing you want, and then use the "Share" item in the toolbar to open the tool that can generate a starting link ("the share blade"). That generated link should have everything you need except the NotebookParams
parameter below.
It shoud look something like below:
https://portal.azure.com/#blade/[name of extension]/[Name of view]/[inputName]/[inputValue]
The name of extension is always AppInsightsExtension
, and the view is either UsageNotebookBlade
if you want the item to be editable, or WorkbookViewerBlade
if you want the item to not be editable. (These are historical names things as they were named when they were created, so it is what it is. we're working on cleaning a lot of this up going forward)
The /inputname/input value
part repeats for each input to the view, and where input value is percent encoded. The parameters you'll probably see set, though there may be more:
ComponentId/[a url encoded resource/other id]
(component id is like the "folder" where the workbook is, it could be inside "Azure Monitor" or it could be inside a specific virtual machine and this value could be a full azure resource id, etc)
ConfigurationId/[a url encoded workbook resource id, or community template id]
the configuration id may also be a template id, like "Community-[id]" instead of a resource id to a specific workbook. If a saved workbook, you'll see a full azure resource id like /subscriptions/blah/resourcegroups/blah/providers/microsoft.insights/workbooks/id
, which will need to be encoded as well, so you'd end up with something like %2Fsubscriptions%2Fblah%2Fresourcegroups%2Fblah%2Fresourceprovider.resource%2Ftype%2Fid
The input you are specifically asking about to set some specific params to the workbook is called NotebookParams
NotebookParams/[encoded params]
Where encoded params in a url is a percent encoded string of the JSON serialized dictionary of key/value params. (For time range params itβs a object with durationMs
field and possibly more if custom time range was set, you can look in a workbook advanced mode JSON after setting the param to see the exact thing you need). In this example, I have a time range param named βtimeRangeβ set to 5 minutes, and a text param called βparamBβ set to βbananaβ
{ββββββ"timeRange": {ββββββ "durationMs": 300000 }βββββββββββββββββββββββββββββββββββββββββ, "paramB": "banana" }βββββββββββββββββββββββββββββββββββββββββββββββββββββββ
which get percent encoded (including spaces=%20 instead of spaces = +) to:
%7B%22timeRange%22%3A%20%7B%20%22durationMs%22%3A%20300000%20%7D%2C%20%22paramB%22%3A%20%22banana%22%20%7D%0D%0A
The names of parameters must match exactly with those in the content for them to be hooked up, and they also need to be at the "top level" of the workbook. (this won't generally work with parameters nested inside other groups)
The full url would then look something like:
https://portal.azure.com/#blade/AppInsightsExtension/UsageNotebookBlade/ComponentId/%2Fsubscriptions%2Fblah%2Fresourcegroups%2Fblah%2Fresourceprovider.resource%2Ftype%2Fnameofresource/ConfigurationId/%2Fsubscriptions%2Fblah%2Fresourcegroups%2Fblah%2Fproviders%2Fmicrosoft.insights%2Fworkbooks%0000000000-0000-0000-0000-000000000000/NotebookParams/%7B%22timeRange%22%3A%20%7B%20%22durationMs%22%3A%20300000%20%7D%2C%20%22paramB%22%3A%20%22banana%22%20%7D%0D%0A
But: Please, please, please do not do this to set up an "autorefresh" script in a browser to repeatedly reload the workbook from scratch. Use the Autorefresh feature in the toolbar instead. Autorefresh inside workbooks re-runs the queries on a schedule, which is a LOT lighter weight than loading the whole portal, all of its dependencies, our extension, all of our dependencies, etc.
If autorefresh doesn't work for you, fill out feedback inside workbooks in the Azure Portal or send me mail first initial j, lastname gardner @ microsoft with your details for your scenario.