'parsing Azure id using regex
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
Solution 1:[1]
Try using this syntax:
| parse kind=regex id with 'machines/' vmanme '/extensions'
Does it work for you?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | lemon |
