I am very new to Azure CLI and having problems in converting the following command
Set-AzCognitiveServicesAccount -ResourceGroupName rg-xxx -Name cs-xxx -DisableLocalAuth $false
Any help will be greatly appreciated.
Thanks in advance.
BR
I have reproduced in my environment and received same error as you have as below and I followed Microsoft-document:
az cognitiveservices account update --name YY -g XX --disable-local-auth $false
XX- Name of resource group
YY- Name of cognitive service
The above error states that az cognitiveservices account update command does not support argument --disable-local-auth .
This command only supports --name --resource-group --api-properties --custom-domain --encryption --sku --storage --tags arguments.
Alternatively, you can use Rest-Api to enable or disable local auths.
Related
I'm trying to run the sample script found here: https://learn.microsoft.com/en-au/azure/service-fabric/service-fabric-quickstart-containers-linux#create-a-service-fabric-cluster
#!/bin/bash
# Variables
ResourceGroupName='containertestcluster'
ClusterName='containertestcluster'
Location='eastus'
Password='q6D7nN%6ck#6'
Subject='containertestcluster.eastus.cloudapp.azure.com'
VaultName='containertestvault'
VmPassword='Mypa$$word!321'
VmUserName='sfadminuser'
# Login to Azure and set the subscription
az login
az account set --subscription <mySubscriptionID>
# Create resource group
az group create --name $ResourceGroupName --location $Location
# Create secure five node Linux cluster. Creates a key vault in a resource group
# and creates a certficate in the key vault. The certificate's subject name must match
# the domain that you use to access the Service Fabric cluster. The certificate is downloaded locally.
az sf cluster create --resource-group $ResourceGroupName --location $Location --certificate-output-folder . --certificate-password $Password --certificate-subject-name $Subject --cluster-name $ClusterName --cluster-size 5 --os UbuntuServer1604 --vault-name $VaultName --vault-resource-group $ResourceGroupName --vm-password $VmPassword --vm-user-name $VmUserName
From the command prompt or PowerShell, I run "az login" and login, then I copy & paste this script into the console but get errors when it comes to the variables.
I see you use the Shell script, it's more appropriate to run in Linux. For Windows, the PowerShell script is more suitable. And in Windows, the variables need to be set like this:
$varName = 'xxxx'
So you need to change all the variables like above. And I suggest you change the script into a PowerShell script.
I was using the following command
$cogVisionEndpoint = (az cognitiveservices account show -n $accountName -g $resourceGroupName --query endpoint --output tsv)
but I found out that this stopped working when I ran this on another machine with a slightly newer version of Azure-CLI.
The JSON returned by the az cognitiveservices account show command is not consistent and looks like it has changed from version to a version.
How can I reliably get this not having to worry about the version of Azure CLI on the machine that I'm running on?
Or is there a completely different way to get the endpoint value?
With the newest version you will find endpoint in properties and since you rely on CLI version installed on the given machine you can simply modify your code to something like this:
$cogVisionEndpoint = (az cognitiveservices account show -n $accountName -g $resourceGroupName --query endpoint --output tsv)
if( !$cogVisionEndpoint ) {
$cogVisionEndpoint = (az cognitiveservices account show -n $accountName -g $resourceGroupName --query "properties.endpoint" --output tsv)
}
I have a Powershell script using Azure Powershell to update an Virtual Machine Scale Set (under Azure Service Fabric) to add/remove the certificates that are used by the associated service fabric virtual machines. This script works as intended and I have the following commands (I've removed some of the other logic to focus on the issue):
# This gets the Virtual Machine Scale Set object
$virtualMachineScaleSet = Get-Azvmss -ResourceGroupName $myResourceGroupName -VMScaleSetName $myVMScaleSetName
# Example of removing items from certificate items from the VMSS object.
$virtualMachineScaleSet.VirtualMachineProfile.osProfile.Secrets[$mySecretIndex].VaultCertificates.RemoveAt($myCertificateIndexThatIWantToRemove)
# Example of creating new certificate config
$newCertificateUrl = (Get-AzKeyVaultCertificate -VaultName $myKeyvaultName -Name $myCertificateName).SecretId
$newCertificateConfig = New-AzvmssVaultCertificateConfig -CertificateUrl $newCertificateUrl -CertificateStore "My"
# Example of adding new certificate to the VMSS object
$virtualMachineScaleSet.VirtualMachineProfile.OsProfile.Secrets[$mySecretIndex].VaultCertificates.Add($newCertificateConfig)
# Committing the update to VMSS
Update-Azvmss -ResourceGroupName $myResourceGroupName -VirtualMachineScaleSet $virtualMachineScaleSet -VMScaleSetName $myVMScaleSetName
The above script works fine. However, I'm now trying to convert each of the above commands to Azure CLI. The way the script will invoke means that I cannot mix and match Azure Powershell and Azure CLI commands in the same script. The commands I have so far are causing problems:
# This gets me the Virtual Machine Scale Set object
$virtualMachineScaleSet = az vmss show --name $myVMScaleSetName --resource-group $myResourceGroupName | ConvertFrom-Json
# Trying to RemoveAt gives the error: MethodInvocationException: Exception calling "RemoveAt" with "1" argument(s): "Collection was of a fixed size."
$virtualMachineScaleSet.VirtualMachineProfile.osProfile.Secrets[$mySecretIndex].VaultCertificates.RemoveAt($myCertificateIndexThatIWantToRemove)
# Not sure the CLI equivalent commands of this
$newCertificateUrl = (Get-AzKeyVaultCertificate -VaultName $myKeyvaultName -Name $myCertificateName).SecretId
$newCertificateConfig = New-AzvmssVaultCertificateConfig -CertificateUrl $newCertificateUrl -CertificateStore "My"
# Trying to Add gives the error: MethodInvocationException: Exception calling "RemoveAt" with "1" argument(s): "Collection was of a fixed size."
$virtualMachineScaleSet.VirtualMachineProfile.OsProfile.Secrets[$mySecretIndex].VaultCertificates.Add($newCertificateConfig)
So my questions are.
What are the CLI equivalent commands for the Azure Powershell script?
Why doesn't the VMSS object in the Azure CLI script seem to be the same? (At least in that I cannot change the VaultCertificates array)
Thank you in advance
All the PowerShell you used can change into two equivalent CLI commands.
One for remove:
az vmss update --resource-group $myResourceGroupName --name $myVMScaleSetName --remove virtualMachineProfile.osProfile.secrets index
One for add:
az vmss update --resource-group $myResourceGroupName --name $myVMScaleSetName --add virtualMachineProfile.osProfile.secrets '{"sourceVault": {"id": "resourceId"},"vaultCertificates": [{"certificateStore": null,"certificateUrl": "certificateUrl"}]}'
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
I'm working on a Azure Cli project (can't use Powershell), but i have a problem with one Azure cli command.
This is a good Powershell command :
Get-AzureRmResource -ResourceGroupName -ResourceType Microsoft.Web/serverfarms/usages -ResourceName "" -ApiVersion 2018-02-01
I can't do the same with CLI (i can't access to Usage part :
az resource show --resource-group --resource-type 'Microsoft.Web/serverfarms/usages' --name '' --api-version '2018-02-01'
=> This command give me the result of the serverfarms information.
How access to the usages level to obtain the FileSystemStorage value ?
Thank you in advance for your help.
Best regards,
Florent.