0

I am trying to update my APIM with a new hostname using the Azure CLI.

When doing this

$hostConfiguration = '[{ "hostName": "myhostname.com", "type": "Proxy", "keyVaultId": "https://mykeyvault.vault.azure.net/secrets/mysecret" }]' az apim update --name "apim-name" --resource-group "rg-name" --set hostnameConfigurations=$hostConfiguration 

I get this :

Unable to build a model: Cannot deserialize as [HostnameConfiguration] an object of type <class 'str'>, DeserializationError: Cannot deserialize as [HostnameConfiguration] an object of type <class'str'> 

What is wrong with the way I do it?

1 Answer 1

1

You will have to convert the json to string before storing in a variable.

I made use of https://tools.knowledgewalls.com/jsontostring to convert your json to string

enter image description here

Updated Snippet

$hostConfiguration ='[{\"hostName\":\"myhostname.com\",\"type\":\"Proxy\",\"keyVaultId\":\"https:\/\/mykeyvault.vault.azure.net\/secrets\/mysecret\"}]' az apim update --name "apim-name" --resource-group "rg-name" --set hostnameConfigurations=$hostConfiguration 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.