Sanners
Sanners

Reputation: 41

Azure Monitor Workbooks - How to make updates via code?

I'm using New-AzResourceGroupDeployment to deploy an Azure Workbook. This works fine when im deploying a new workbook, but is it possible to make updates to that workbook via this cmdlet (or az deployment group create)?

If I deploy over the top (I have relevant level of access), I get the following:

Status Message: A Workbook with the same name already exists within this subscription. (Code:Conflict)

The portal does allow editing of an existing workbook, how do I replicate this via code? I can't seem to find a update- cmdlet or equivalent.

thanks

Upvotes: 1

Views: 1433

Answers (2)

daviesdoesit
daviesdoesit

Reputation: 843

GitHub - John Gardner post

Yes, @dibyendupal05, that (without the exact [newGuid()] code was what i meant when i posted a few replies back:

if you're using a new guid for workbookId every time, you aren't creating the same workbook again. you're creating a new workbook with a new id, but reusing the same display name, which conflicts with something else with the same name.

the default assumption in our samples is that you want a new workbook. If you're modifying this to create/update the same workbook you'd have to set an explicit id somewhere, otherwise you will get the error about duplicate names.

As dibyendupal05 says, if you want to use a template to update an existing resource, you can't use newGuid inside, you have to explicitly set an id, and keep using that id, so that you can run the same template and update the same workbook, instead of attempting to create a new workbook that just happens to have the same display name.

Upvotes: 0

John Gardner
John Gardner

Reputation: 25126

the "display name" of the workbook is used as the "nice" name, however, workbooks have a unique id as well.

chances are, you have newguid or something in the template which is creating a new resource id every time you run the template, it just happens to have the same "friendly/display name" which is what users normally see.

(this distinction exists because the portal has rules about what characters can be in resource id values, but we didn't want to limit workbooks users from only using [a-z0-9_] to name their workbooks)

if you want to overwrite the same workbook again, you'll need to update the template to properly also resuse the id portion of the template, so that ARM tries to update the same resource instead of creating a new workbook with a different id but having the same display/friendly name?

Upvotes: 1

Related Questions