az keyvault key rotation-policy update - CLI supported version - azure

From which CLI version below mentioned CLI command is supported
az keyvault key rotation-policy update

As mentioned in MsDoc, Azure CLI version 2.42.0 or above is needed to update az key vault rotation key policy.
To upgrade azure CLI use:
az upgrade --yes
If you are already up to date, the output is as seen above.
After checking the prerequisites, I ran below command with retention policy taken in json file and able to update the key vault rotation successfully.

Related

--no-wait tag not working when using az resource delete

I am trying to delete a virtual machine using the command below
az resource delete --ids /subscriptions/0b1f6471-1bf0-4dda-aec3-111111111111/resourceGroups/MyResourceGroup/providers/Microsoft.Network/virtualMachines/vmlname1 --no-wait
I am getting this error:
unrecognized arguments: --no-wait
When I remove --no-wait it works
By this link:
https://learn.microsoft.com/en-us/cli/azure/resource?view=azure-cli-latest#az-resource-delete-optional-parameters
no-wait is given as a valid parameter
--no-wait
Do not wait for the long-running operation to finish.
Can anyone tell me, whether it is possible to use --no-wait in az resource delete ?
Update:
This is the az cli version i am using:
{
"azure-cli": "2.40.0",
"azure-cli-core": "2.40.0",
"azure-cli-telemetry": "1.0.8",
Thanks
It is possible to use the --no-wait flag with the az resource delete command. My testing using the flag did not produce the error that you are seeing. Is it possible that your azure cli is not up to date?
You can upgrade your azure cli to the latest version by following these instructions.
I have reproduced in my environment and got below results:
I have one VM named srivm with Resource ID like below:
When I ran the same command as you to delete VM, I got same error as below:
az resource delete --ids /subscriptions/<subID>/resourceGroups/<rgname>/providers/Microsoft.Network/virtualMachines/<vmname> --no-wait
Response:
Note that, the current version of the Azure CLI is 2.43.0. The error may occur if the CLI version is less than latest version.
When I checked the az version, I got response like below:
To resolve the error, upgrade your CLI version to latest version with az upgrade command or download azure-cli-2.43.0.exe directly.
After installing the latest version, I'm able to delete the VM successfully after running below command:
az resource delete --ids /subscriptions/<subID>/resourceGroups/<rgname>/providers/Microsoft.Network/virtualMachines/<vmname> --no-wait
Response:
To confirm that, I checked Portal and VM deleted successfully like below:

deploying function app via AZ CLI fails with tooling error

I have 2 different function apps and deployment scripts. The first app (functionApp1) uses the az cli, and the second one is being written to use the new AZ Powershell modules.
I thought I wouldn't be impacting the az cli solution by installing/setting up the latest powershell cmdlets but I think functionApp1's deployment is broken since installing the new Az Powershell tools.
When I run the az cli deployment script for function App 1, it dies while trying to publish the application. The error message says:
You're trying to use v4 tooling to publish to a non-v4 function app
(FUNCTIONS_EXTENSION_VERSION is set to ~3). You can pass --force to
force update the app to v4, or downgrade tooling for publishing.
Code
In case it helps, here are some snippets of code from the deployment script for functionApp1 The following logic to create a resource group, application insights, and a storage account all works:
az login --service-principal --username $CLIENT_ID --password $SECRET --tenant $TENANT --allow-no-subscriptions
az account set --subscription $SUBSCRIPTION_ID
az group create -n $RESOURCE_GROUP_NAME -l $RESOURCE_LOCATION
az deployment group create --resource-group $RESOURCE_GROUP_NAME --template-file (Join-Path $PSScriptRoot "./resources/function1App.json")
Next I grab information from the new resources I created above, and I update my local.settings.json file. This also still works:
func settings add FUNCTIONS_WORKER_RUNTIME dotnet #explicitly set this.
#auto-update the local.settings.json file with connection string
func azure storage fetch-connection-string $storageAccount.name
#grab contents of local settings file.
$data = Get-Content 'local.settings.json' -raw | ConvertFrom-Json
#logic to update local settings.
Lastly I try to publish the functions in azure using my local settings file. And this is the part that is no longer working:
$functionDeploymentResult = func azure functionapp publish $FUNCTION_APP.name --publish-local-settings -i --overwrite-settings -y
But the error message I'm getting is this:
You're trying to use v4 tooling to publish to a non-v4 function app (FUNCTIONS_EXTENSION_VERSION is set to ~3).
You can pass --force to force update the app to v4, or downgrade tooling for publishing.
I tried to add the --force option and while it gets rid of the error message, when I try to actually run my test "hello world" function in azure, I see the following error message:
Microsoft.Azure.WebJobs.Script: One or more loaded extensions do not meet the minimum requirements. For more information see https://aka.ms/func-min-extension-versions.
ExtensionStartupType AzureStorageWebJobsStartup from assembly 'Microsoft.Azure.WebJobs.Extensions.Storage, Version=4.0.3.0, Culture=neutral, PublicKeyToken=asdfasdfasdf' does not meet the required minimum version of 4.0.4.0. Update your NuGet package reference for Microsoft.Azure.WebJobs.Extensions.Storage to 4.0.4 or later.
AZ CLI VERSION
PS C:\Users\me\Documents\src\functionapp1> az --version
azure-cli 2.30.0 *
core 2.30.0 *
telemetry 1.0.6
Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'
Extensions directory 'C:\Users\me\.azure\cliextensions'
Python (Windows) 3.8.9 (tags/v3.8.9:a743f81, Apr 6 2021, 13:22:56) [MSC v.1928 32 bit (Intel)]
Legal docs and information: aka.ms/AzureCliLegal
You have 2 updates available. Consider updating your CLI installation with 'az upgrade'
Please let us know how we are doing: https://aka.ms/azureclihats
and let us know if you're interested in trying out our newest features: https://aka.ms/CLIUXstudy
.vscode/settings.json
{
"azureFunctions.deploySubpath": "src/bin/Release/netcoreapp3.1/publish",
"azureFunctions.projectLanguage": "C#",
"azureFunctions.projectRuntime": "~3",
"debug.internalConsoleOptions": "neverOpen",
"azureFunctions.preDeployTask": "publish (functions)"
}
I'm presently trying to do some research on how / what specifically to downgrade but any tips / suggestions would be appreciated.
Azure PowerShell does not interfere with Azure cli installation.
Based on the error message, it looks like the version of the Azure function tools you are using is v4 but the function app that you have deployed is v3 (likely defined so in the ARM template that you are using).

Resize vmss in azure using azure cli

I want to update size of vmss from Standard_F16s_v2 to Standard_F32s_v2 I usually do it from Ui
but for some requirement I have to do it from a script so I tried to follow the documentation
https://learn.microsoft.com/en-us/cli/azure/vmss?view=azure-cli-latest
and tried to run this command
az vmss update --name MyScaleSet --resource-group MyResourceGroup --vm-sku Standard_F32s_v2
but it is not working shows error UnrecognizedArgumentError: unrecognized arguments: --vm-sku Standard_F32s_v2
The issue was with a previous version of az CLI which was resolved by upgrading it to version 2.30.0.
Test Scenario :

az storage container list. doesnt work, referencing deleted storage

I am following this tutorial, running az cli(v 2.11) on my MacOS locally:
https://learn.microsoft.com/en-us/learn/modules/provision-infrastructure-azure-pipelines/6-run-terraform-remote-storage
after following a few steps including this one:
az storage account create --name tfsa$UNIQUE_ID --resource-group tf-storage-rg --sku Standard_LRS
and have run this command:
az storage container list --query "[].{name:name}" --output tsv
i receive the following:
HTTPSConnectionPool(host='mystorageaccount20822.blob.core.windows.net', port=443): Max retries exceeded with url: /?comp=list&maxresults=5000 (Caused by NewConnectionError('<urllib3.connection.VerifiedHTTPSConnection object at 0x10d2566a0>: Failed to establish a new connection: [Errno 8] nodename nor servname provided, or not known'))
The above command works in cloud shell, but fails in my local shell (running v 2.20, up to date)
on cloud shell i do get this warning though:
There are no credentials provided in your command and environment, we
will query for the account key inside your storage account. Please
provide --connection-string, --account-key or --sas-token as
credentials, or use --auth-mode login if you have required RBAC
roles inyour command. For more information about RBAC roles in
storage, visit
https://learn.microsoft.com/en-us/azure/storage/common/storage-auth-aad-rbac-cli.
I had previously created a mystorageaccount20822 a couple weeks ago but deleted it... my AZ CLI is still bound to this previous account? Is there a way to tell my az cli (on mac) to sync up with the current resources i have running. In Azure Portal mystorageaccount20822 does NOT exist.
Does Azure CLI cache some values or something? is there some hidden config file that has the old 'mystorageaccount20822' set and the CLI is trying to reference that each time instead of the new account named tfsa$UNIQUE_ID ?
After running the command with debug:
az storage container list --debug --account-name tfsa$UNIQUE_ID --query [].name --output tsv
I was able to see that it was setting it.
It turns out it had set the environment variable 'AZURE_STORAGE_CONNECTION_STRING' from a tutorial a few days ago, which was overriding a property when the command was sent, to use an old examples value. After unsetting that environment variable, the command worked.

az storage account: 'blob-service-properties' is not in the 'az storage account' command group

I want to enable versioning, Change Feed in Azure storage account using CLI. I got the below command from the Microsoft document https://learn.microsoft.com/en-us/cli/azure/storage/account/blob-service-properties?view=azure-cli-latest.
az storage account blob-service-properties update -n sdffsjhiwezzaz --enable-change-feed true --enable-versioning true --enable-delete-retention true --delete-retention-days 100
And got the below error
az storage account: 'blob-service-properties' is not in the 'az storage account' command group. See 'az storage account --help'.
Kindly tell me how to enable versioning and ChangeFeed using Azure CLI
I am using azure-cli 2.27.1 and found that this worked. No the syntax is slightly different
az storage blob service-properties update --account-name mystorageaccount --delete-retention true --delete-retention-period 5
https://learn.microsoft.com/en-us/cli/azure/storage/blob/service-properties?view=azure-cli-latest#az_storage_blob_service_properties_update
I am able to run the command successfully. Please ensure that you have the latest version of CLI installed.
When I run az --version command, this is what I see:
azure-cli 2.2.0
command-modules-nspkg 2.0.3
core 2.2.0
nspkg 3.0.4
telemetry 1.0.4
Also for change feed, you will need to register your subscription for this feature as it is currently in preview. You can find instructions about it here: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-change-feed?tabs=azure-portal#register-your-subscription-preview.

Resources