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.
Related
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.
I have a number of instance running under my app service in Azure. I need to get back all the id's of these instances.
I am currently using
Get-AzureRmResource -ResourceGroupName $ResourceGroupName -ResourceType
Microsoft.Web/sites/instances -Name $WebAppName -ApiVersion 2016-03-01
But is there an equivalent command using the az cmdlets ?
I've tried the exact PowerShell command that you executed in Azure PowerShell. I could be able to get the expected results as shown:
I've tried to get the desired outcome with AZ cmdlet(Bash) and received the expected results using:
az webapp list-instances
To get the instances running info with their respective ID's on app service in Azure:
az configure --defaults group=xxxxResourceGroupName
az configure --defaults web=xxxxwebapp
az webapp list-instances --name xxxxwebappp --resource-group xxxxResourceGroupName
If you want to retrieve "default hostname, EnabledHostName as well as state" of WebApp, Use below command as shown:
Refer MSDoc az.webapp cmdlets
It is always recommended to use latest Az PowerShell module cmdlets instead of AzureRM since AzureRm is going to retire soon.
In the above answer shared by #jahanvi replace Get-AzureRMResource with Get-AzResource which is a relevant Az module cmdlet.
Alternatively, you can use the Azure Management RestAPI to get the list of instances running under a particular webapp using Invoke-RequestMethod you call the rest api from powershell as well.
Here is the sample script:
Connect-AzAccount
$context=Set-AzContext -Subscription "<subscriptionId>"
$token = Get-AzAccessToken
$authHeader=#{
'Content-Type'='application/json'
'Authorization'='Bearer '+ $token.Token
}
$instances=Invoke-RestMethod -Uri https://management.azure.com/subscriptions/<subscriptionId>/resourceGroups/<resourceGroupName>/providers/Microsoft.Web/sites/<WebAppName>/instances?api-version=2022-03-01 -Method GET -Headers $authHeader
$instances.value.id
Here is the sample screenshot for reference:
We have windows webapp in Azure, we want to change the stack to dotnet core version(3.1,2.1) using Azure cli.
If it is a linux webapp, we can use az webapp config set -g $group -n $webappName --linux-fx-version "DOTNETCORE|2.1". But for windows couldn't find anything. Help is appreciated.
Thank you!
In our local environment(webapp is running on Windows app service plan), using the below cmdlet initially we have changed the .Net version to 6.0
az webapp config set -g "<RGName>" -n "<WebAppName>" --net-framework-version "v6.0"
later, we have downgraded the version(v4.0) using the below cmdlet & we are able to get the .NetCore(3.1,2.1) in our webapp configuration.
az webapp config set -g "<RGName>" -n "WebAppName>" --net-framework-version "v4.0"
Using the below powershell script, am able to achieve this.
Set-AzWebApp -ResourceGroupName 'MyRG' -Name 'MyWebApp' -AppServicePlan ' MyWebAppPlan'
$PropertiesObject = #{"CURRENT_STACK" = "dotnetcore"}
New-AzResource -PropertyObject $PropertiesObject -ResourceGroupName 'MyRG' -ResourceType Microsoft.Web/sites/config/metadata -ResourceName 'MyWebApp' -ApiVersion 2021-03-01 -Force
Refer this github issue for more information:- https://github.com/Azure/azure-cli/issues/21192
I want to use azure cli command to change the reference image of vmss and update the vm running under the vmss.
I used to use UI to update the reference image as shown below.
I tried following https://learn.microsoft.com/en-US/cli/azure/vmss?view=azure-cli-latest#az_vmss_update
but not getting exact command, am I going in wrong direction?
I have tested in my environment to change the reference images of VMSS but it seems not possible using below cmd.
Update-AzVmss ` -ResourceGroupName "myResourceGroup" ` -VMScaleSetName "myScaleSet" ` -ImageReferenceId /subscriptions/{subscriptionID}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/images/myNewImage
If you want to update the version of reference image you can change with the below command.
Update-AzVmss -ResourceGroupName "myResourceGroup" -VMScaleSetName "myScaleSet" -ImageReferenceVersion 16.04.201801090
This is the CLI command I have used
az vmss update --name MyScaleSet --resource-group MyResourceGroup --set virtualMachineProfile.storageProfile.imageReference.id=imageID
My deployment script uses PowerShell with the AzureRM module. I am trying to find the equivalent of the following Azure CLI call. That call creates an Azure Function based on a Docker image.
az functionapp create --name <app_name> --storage-account <storage_name> --resource-group myResourceGroup --plan myPremiumPlan --deployment-container-image-name <docker-id>/mydockerimage:v1.0.0
Anybody has an idea what is the PowerShell/AzureRM equivalent of "az functionapp create"?
If your ideal goal is to deploy a function app, there are multiple ways to create one.
You can use the below AzureRm command to provision / create a new Function App
New-AzureRmResource -ResourceType ‘Microsoft.Web/Sites’ -ResourceName $functionAppName -kind ‘functionapp’ -Location $location -ResourceGroupName $resourceGroupName -Properties #{} -force
Or You can use a ARM Template to deploy a function app - Details
Or you can use Zip Deploy to deploy your function app. -
As HariHaran said, there are several ways to create new function app. But if you want to create function based on docker image, it may be difficult to implement if use "New-AzureRmResource". So I think you can install az module in powershell, you can continue use "az functionapp create" commmand, you can refer to this tutorial to install it. But az module will not be compatible with AzureRM, so we'd better uninstall AzureRM before that, you can refer to this page about the compatible of az module and AzureRM.
You can use the New-AzFunctionApp cmdlet which is part of the Az.Functions module. This module is currently in Preview.
# First install PowerShell 6 or 7 from https://github.com/PowerShell/PowerShell/releases
# To install the Az.Functions module, Open PowerShell and run:
Install-Module -Name Az.Functions -AllowPrerelease
Alternatively, you can download it from https://www.powershellgallery.com/packages/Az.Functions/0.0.1-preview
For feedback and requests, please file an issue at https://github.com/Azure/azure-powershell/issues. Make sure you include in the title [Az.Functions]. Thanks!