Enable Health Check in a app service via CLI - azure

Is there any way to enable health check via cli in azure app services? I see that we can modify some configurations but not an option to enable/disable the feature.
Thank you!

According to my test, we can enable/disable health check via changing the value of web config healthCheckPath. For more details, please refer to here.
For example(I test it via azure cloud shell)
a. Enable
az webapp config set -g <groupName> -n <web name> --generic-configurations '{"healthCheckPath": "/api/health/"}'
b.Disable
az webapp config set -g <groupName> -n <web name> --generic-configurations '{"healthCheckPath": ""}'

Thanks to #jim-xu answer I was able to get this working for our needs.
I did struggle trying to make syntax work in an existing PowerShell script with the string quotation marks and making it a variable. I thought I'd put that syntax here in case someone else is trying this via scripts not using bash.
# variables - these might be local or parameters from your function, etc..
$webAppName= "my-web-app"
$resourceGroupName = "my-resource-group"
$healthCheckPath = "/api/health/"
# the important part
$genericConfigurations = "{\""healthCheckPath\"": \""$healthCheckPath\""}"
az webapp config set --name $webAppName `
--resource-group $resourceGroupName `
--generic-configurations $genericConfigurations `
--output none
Yes I did attempt to be conscientious and read through Use Azure CLI effectively - Using quotation marks in values and it still wasn't clear to me.
I saw many other posts with users getting caught on this syntax; example 1, example 2, example 3.

Related

Azure staticwebapp not allowing to add config with "&" in value using Azure CLI in terminal

I am using Azure CLI to use the azure. I am trying to create a staticwebapp and later try to add the configuration from CLI.
I tried to run this
az staticwebapp appsettings set -n appname --setting-names MONGO_CONNECTION_STRING="mongodb+srv://anirudha:testing#cluster4340.v45343.mongodb.net/?retryWrites=true&w=majority"
I am getting error
'w' is not recognized as an internal or external command,
operable program or batch file.
I go to portal and seen before &w=majority is added into configuration but this part is not added after &.
I tried to put singlequote and key=("val") but none of them working for me. I found this in azure app config github repo.
Anyone have idea how to make it work from CLI
--setting-names property accepts the app settings in 'key=value' format as mentioned here in this documentation of az staticwebapp app settings set cmdlet.
You need to change the above shared cmdlet to the below:
az staticwebapp appsettings set -n <staticWebAppName> --setting-names 'MONGO_CONNECTION_STRING=<AppsettingValue>'
I have tested this and it is working fine from my end Here is the sample output screenshot for your reference:
Updated Answer:
Alternatively, you can use this PowerShell cmdlet
(New-AzStaticWebAppSetting) to update the app settings of the static web app
New-AzStaticWebAppSetting -ResourceGroupName resourceGroup -Name staticweb01 -AppSetting #{'function01' = 'value01'; 'function02' = 'value02' }

Az CLI to configure Azure Function App TLS/SSL "HTTPS Only" Setting

I am trying to use Az Cli to configure an Azure Function TLS/SSL Binding to switch the "HTTPS Only" setting from Off to On, as depicted below.
All attempts appear to have failed so far, using either of the below commands.
az webapp config set -g test-poc -n r-egm-test-fc --http20-enabled true
az functionapp config set -g test-poc -n r-egm-test-fc --http20-enabled true
Any ideas on:
Which command I should be using?
What is the correct syntax required to achieve my desired goal?
After some bit of digging around, I manage to find and successfully test the following as the right command:
az functionapp update -n 'r-egm-test-fc' -g 'test-poc' --set httpsOnly=true
Works like a charm !!

az webapp list-runtimes - Powershell equivalent

Does anyone know if there is any equivalent for the az cli command "az webapp list-runtimes" in PowerShell?
Thanks!
There is none I am aware of. However you can anyway fire az cmd from the same powershell session seamlessly if you are already into latest Az powershell.
$rt = az webapp list-runtimes # for linux, add --linux flag
# use $rt like a regular ps variable (would be array in this case)

Problem in Powershell with the --runtime command setting up Jenkins pipeline

I am trying to configure a Pipeline with Jenkins and deploying it to Azure. I am at the last step of a tutorial:
https://learn.microsoft.com/en-us/azure/jenkins/tutorial-jenkins-deploy-web-app-azure-app-service
This last step is as follows, i have to enter this in the Azure CLI:
az group create --name yourWebAppAzureResourceGroupName --location region
az appservice plan create --name appServicePlanName --resource-group rgname --is-linux
az webapp create --name webAppName --resource-group rgName --plan appServicePlanName --runtime "java|1.8|Tomcat|8.5"
The last command gives me the error:
'1.8' is not recognized as an internal or external command,
operable program or batch file.
So I thought maybe Tomcat is not installed on my Azure VM, which is a Linux machine. So I used the next tutorial to install Tomcat:
https://www.howtoforge.com/tutorial/how-to-install-apache-tomcat-8-5-on-ubuntu-16-04/
After this I tried to do the --runtime command again, but I still get the same error. I have no idea how to fix this. I hope someone can help me with this problem.
I tried to check the webapp list-runtimes and I get this list:
"java|1.8|Tomcat|8.5" is in here. I've tried all of the versions, but it did not work.
EDIT: It works in the Azure Cloud Shell, but then there is another error:
Linux Runtime 'java|1.8|Tomcat|8.5' is not supported.Please invoke 'list-runtimes' to cross check
I have tried all the runtime versions, but still this error. I have also tried it with double quotes
I bet you solved your problem already, but in case others find this and are using PowerShell to run Azure CLI commands. This is what worked for me.
The problem is in how PowerShell interprets the pipe, '|', character inside the --runtime parameter, when evaluating the whole line.
Add the --% to be beginning of the command to turn off PowerShell evaluation of expressions, as suggested in the code block here.
Note: this will also stop PowerShell from evaluating any variables inside the command. What you can do is move the --runtime to the end of the line to get around this problem, e.g. like this
az webapp create -g $rg -p $appPlanName -n $appName --deployment-local-git --% --runtime "DOTNETCORE|3.0"
ok, i got it, that list is for windows webapp, not linux. for linux use:
az webapp list-runtimes --linux
so working solution:
az webapp create --name yourWebAppName --resource-group yourWebAppAzureResourceGroupName --plan yourLinuxAppServicePlanName --runtime "TOMCAT|8.5-jre8"

Azure CLI 2.0: az vm update --set/--remove does not work?

I am attempting to remove and set tags on a VM, but am getting the error unrecognized arguments.
For example, removing a tag:
az vm update –-resource-group MyResourceGroup –-name MyTestVM --remove tags.myNewTagName1
and setting a tag:
az vm update --resource-group MyResourceGroup --name MyTestVM –-set tags.myNewTagName1=myNewTagValue1
Both examples are from the documentation. I'm running v2.0.30 on Mac OS 10.12.x.
Can anyone else confirm this and/or have it work for them? I haven't found any bugs listed in the issues db.
Thanks!
I discovered what was wrong. The syntax of the command is correct and works. However, I copied the command out of the documentation and it has a different character for the dashes/hyphens that the AZ CLI does not accept.
If you copy the samples, just re-type the dashes with the standard ones on your keyboard.
I had posted it this as an issue here: https://github.com/Azure/azure-cli/issues/5976

Resources