azure-monitorazure-monitor-workbooks

How to pass workbook parameters in the url to an Azure Monitor Workbook?


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?


Solution

  • 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:

    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.