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?
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
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
Related
I have wrongly deleted the Log Analytics Workspace and moved the Container App Environment to a new group. After that I found out my Container App Environment had the wrong customerId.
"appLogsConfiguration": {
"destination": "log-analytics",
"logAnalyticsConfiguration": {
"customerId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}
},
I tried to change that using the workspace-id using the create command below, but it didn't change. I suppose that workspaceid and customerId are the same, since I checked both.
az containerapp env create \
--name samenameasbefore \
--resource-group newgroup\
--logs-workspace-id newid \
--logs-workspace-key newsecret \
--location westeurope
Is there any documented or undocumented way to change the customerId/workspaceid of a Container App Environment?
Thank you
Short answer, the CAE workspace ID can't be changed. In order to use a specific workspace with a container app you'll need to redeploy it in a CAE that was created with the specific workspace you want to use. Currently there's no CLI command or workaround that would allow for a workspace switch on CAE.
I understand API is in preview but maybe someone can help me out here .
I am trying to create Data container as its described in AML REST API
curl --location --request PUT 'https://management.azure.com/subscriptions/{{subscriptionId}}/resourceGroups/{{resourceGroupName}}/providers/Microsoft.MachineLearningServices/workspaces/{{workspaceName}}/data/abc?api-version=2021-03-01-preview' \
--header 'Authorization: Bearer ' \
--header 'Content-Type: application/json' \
--data-raw '{"properties": { "description": "string",
"tags": { },
"properties": {}
}
}'
I receive 400 status code with message
Error setting value to 'Description' on 'Microsoft.MachineLearning.ManagementFrontEnd.Contracts.V20210301Preview.Assets.DataContainer'."
after removing Description which should be optional
DataContainers_CreateOrUpdate is not supported
How can I create Dataset with local files? I cannot use UI. There it works and I can receive it with GET list method.
If you want to create a dataset from local file, you can use az ml cli. Use following command from a powershell:
az ml dataset create --file data.yaml --resource-group "your-resource-group" --workspace-name "your-ws-name"
data.yaml
$schema: https://azuremlschemas.azureedge.net/latest/dataset.schema.json
name: local-file-example
description: Dataset created from local file.
local_path: data/titanic.csv
See az yaml schema and az dataset cli.
It seems like API version 2021-03-01-preview is not working properly for dataset operations. By reverse-engineering the az CLI command mentioned by qiax using the --debug option I could see that the endpoint used by the CLI is the following:
https://management.azure.com/subscriptions/{subscription-id}/resourceGroups/{resource-group}/providers/Microsoft.MachineLearningServices/workspaces/{workspace}/datasets/{dataset-name}/versions/1/?api-version=2021-10-01
Here's an example of a valid request body for that endpoint (it seems like it's the same as the Create Or Update Data Version endpoint shown in the documentation):
{
"properties": {
"isAnonymous": false,
"paths": [
{
"file": "foo/"
}
],
"properties": {},
"tags": {}
}
Trying to create a new azure eventgrid endpoint subscription based on the code in the Microsoft tutorial here errors:
az eventgrid event-subscription create --source-resource-id $topicid --name eventsubscriptionname --endpoint-type storagequeue --endpoint $queueid --expiration-date "2020-05-15"
Deployment failed. Correlation ID: xxxx. The attempt to validate the provided azure endpoint resource:xxxx failed.
The tutorial says to ensure the account has write access to the storage, which it does, I am the owner. All properties in the command have valid values and I am executing from the azure cli.
What could I be doing wrong?
That's weird... I tried on my side and I have the expected result using the following commands :
$resourcegroup="your resource group"
$storagename="your storage name"
$queuename="your queue name"
$topicname="your topic name"
$subscriptionname="your subscription name"
$storageid=az storage account show --name $storagename --resource-group $resourcegroup --query id --output tsv
$queueid="$storageid/queueservices/default/queues/$queuename"
$topicid=az eventgrid topic show --name $topicname -g $resourcegroup --query id --output tsv
az eventgrid event-subscription create --source-resource-id $topicid --name $subscriptionname --endpoint-type storagequeue --endpoint $queueid --expiration-date "2020-05-15"
I sued PowerShell version 5.1.18362.752 and AZ CLI version 2.5.1
I have a File Share setup in a Storage Account. When I try to mount it in my Web App I get the following response:
"nexport-shared": {
"accessKey": "hidden==",
"accountName": "hidden",
"mountPath": "\\\\nexportshared",
"shareName": "nexportcampusbetashare",
"state": "InvalidCredentials",
"type": "AzureFiles"
}
I am using the az CLI command below :
az webapp config storage-account add --resource-group "GROUPNAME" --name "WEBAPPNAME" --custom-id nexport-shared --storage-typeAzureFiles --share-name nexportcampusbetashare --account-name STORAGEACCOUNT --access-key "hidden==" --mount-path "\\nexportshared" --verbose --debug
When I run 'az webapp config list' it shows up in the list but still with InvalidCredentials
A possible reason is that you have input an invalid key or storage account to mount the Azure files. Correcting these parameters fixes this issue for me.
Fixed as below
You may need to turn off or modify the firewall on the storage account for the Azure-Cli and the App Service to be able to see it.
I'm getting same response and file share is working as expected.
Also I just found an issue created about this, seems to be an error in the response message from the API:
https://github.com/Azure/azure-cli/issues/21571
After installing the latest Az module in Powershell I can install the webapp extension AspNetCoreRuntime.3.0.x86 using the following command:
New-AzResource -ResourceGroupName '<resource-group>' -ResourceType 'Microsoft.Web/sites/siteextensions' -Name '<webapp-name>/AspNetCoreRuntime.3.0.x86' -ApiVersion '2018-02-01'
Now I want the same results using azure-cli:
az resource create --resource-group '<resource-group>' --resource-type 'Microsoft.Web/sites/siteextensions' --name '<webapp-name>/AspNetCoreRuntime.3.0.x86' --api-version '2018-02-01'
but when executed it requires an extra argument --properties but I cann't find any documentation regarding this argument. If I provide an empty json object the operation fails:
az : ERROR: Operation failed with status: 'Not Found'. Details: 404
Client Error: Not Found for url ....
How can I solve this problem using Azure CLI?
The --name should be --name '<webapp-name>/siteextensions/AspNetCoreRuntime.3.0.x86', also append --properties '{}'.
Try the sample as below, it works fine on my side.
az resource create --resource-group '<resource-group>' --resource-type 'Microsoft.Web/sites/siteextensions' --name '<webapp-name>/siteextensions/AspNetCoreRuntime.3.0.x86' --api-version '2018-02-01' --properties '{}'
Just try --properties {}
If their aren't actually any mandatory properties this will make CLI happy