Closed DahliaRane closed 4 months ago
@DahliaRane hmm, can you check the pe in the portal (json view) and see if the key 'provisioner'/'Provisioner' is reasonable?
I could not find the key 'provisioner'/'Provisioner' in any private end point for the subscription it failed.
can you try this:
$subscriptionId = "subId" #example: fb66b6e2-879e-4e99-97a8-72c767d9bd75
$uri = "https://management.azure.com/subscriptions/$($subscriptionId)/providers/Microsoft.Network/privateEndpoints?api-version=2022-05-01"
$method = 'GET'
$res = Invoke-AzRestMethod -Uri $uri -Method $method
$resObj = ($res.Content | ConvertFrom-Json)
$resObjAsHashtable = ($res.Content | ConvertFrom-Json -AsHashtable)
ConvertFrom-Json:
Line |
6 | $resObj = ($res.Content | ConvertFrom-Json)
| ~~~~
| Cannot convert the JSON string because it contains keys with different casing. Please use the -AsHashTable switch instead. The key that was attempted to be added to the existing key 'Provisioner' was 'provisioner'.
When I remove the line $resObj = ($res.Content | ConvertFrom-Json) it worked
well, now you can inspect the PEs to find the keys with different casing. Curious to see what/why..
"tags": { "AppName": "", "CostCenter": "", "Environment": "dev", "Provisioner": "Terraform", "module_name": "private_endpoint", "module_version": "1.1.0", "provisioner": "Terraform", "test_tag": "Testing Dev" },
so, is the tagName with differing casing intended?
I am not sure but seeing the values I think the two different cases are referring same value.
In some other private endpoints i don't see lower case "provisioner".
"tags": {
"AppName": "",
"CostCenter": "",
"Environment": "",
"Provisioner": "Terraform",
"UseCase": "Vault",
"module_name": "private_endpoint",
"module_version": "1.1.0"
}
I need to think about handling such scenarios with the azapicall/azgovviz.. not sure how common such scenario is, can you check with the team that deployed that PE with terraform?
Its quite common . We have some subscriptions which has such scenarios.
@DahliaRane sorry for the delay. In general, Azure resource JSON do not come with multicased keys. In your case the Tags are the problem / such issue has not been reported before (so I assume a rare edge case here).
Ok looks like we cant delete keys which are multicased for some restrictions. Can you let me know where to modify the code or some solution for this rare edge case.
give it a try using the parameter -noNetwork.
Can you share some insights why you are using these multicased tagsNames?
@DahliaRane any update from your side?
'Getting Private Endpoints for Subscription: -----------Command 'ConvertFrom-Json' failed: Cannot convert the JSON string because it contains keys with different casing. Please use the -AsHashTable switch instead. The key that was attempted to be added to the existing key 'Provisioner' was 'provisioner'. [AzAPICall 1.2.1] 'Getting Private Endpoints for Subscription------------------Trying command 'ConvertFrom-Json -AsHashtable'
[AzAPICall 1.2.1] 'Getting Private Endpoints for Subscription--------------------Command 'ConvertFrom-Json -AsHashtable' succeeded. Please file an issue at the AzGovViz GitHub repository (aka.ms/AzGovViz) and provide a dump
[AzAPICall 1.2.1] 'Getting Private Endpoints for Subscription-------------------Command 'ConvertFrom-Json -AsHashtable' failed. Please file an issue at the AzGovViz GitHub repository (aka.ms/AzGovViz) and provide a dump (scrub subscription Id and company identifyable names) of the resource (portal JSOn view) - Thank you!