parsing Azure id using regex

Viewed 176

I have following id that I would need to parse so that I could use only the vm name of id but can't figure this out

/subscriptions/0000x0000x0000x000/resourceGroups/MyResourceGroup/providers/Microsoft.HybridCompute/machines/MyVirtualMachine/extensions/MyAgent

I have tried following lines but I have not gotten it work

| parse kind=regex id with '/machines/' vmanme
| parse kind=regex id with * 'machines=' machines
| parse kind=regex id with "(.*?)[a-zA-Z]*=" machines @"
| parse kind=regex id with  with * "machines=" machines ',' *
| parse kind=regex flags = Ui  id with * "MACHINES=" machines ',' *

Best try I had with | parse kind=regex id with '/machines/' vmanme but then I outputted a bit too much: /MyVirtualMachine/extensions/MyAgent insted only outputting MyVirtualMachine

1 Answers

Try using this syntax:

| parse kind=regex id with 'machines/' vmanme '/extensions'

Does it work for you?

Related