Azure WebApp - Unable to auto-detect the runtime stack of your app - azure

I'm trying to create Web App which is just having a Static HTML. I'm following this link https://learn.microsoft.com/en-us/azure/app-service/app-service-web-get-started-html. But when I execute the following command
az webapp up --location westeurope --name .
Got the error - " Could not auto-detect the runtime stack of your app" .

I tried the following, but added the --html flag at the end of the az webapp up command to bypass auto detection:
mkdir quickstart
cd quickstart
git clone https://github.com/Azure-Samples/html-docs-hello-world.git
cd html-docs-hello-world
az webapp up --location westeurope --name azurewebapptest123 --html
That forces HTML. In the help for the command it implies auto-detection works for a bunch of language, but not for static HTML.

I just tried following the steps mentioned in the documentation. Works for me.
mkdir quickstart
cd quickstart
git clone https://github.com/Azure-Samples/html-docs-hello-world.git
cd html-docs-hello-world
az webapp up --location westeurope --name azurewebapptest123

I have tried the similar steps using the sample repo and was able to reproduce it.
Here is the version:
It's a known bug for Azure CLI 2.0.78 and team is working on it, Which you can track it here:
https://github.com/MicrosoftDocs/azure-docs/issues/43633
Work around of this issue is to use the older version of Azure CLi e.g. 2.0.75 * for deploying the solution.
Hope it helps.

Try to manually include a web.config file and/or select the stack on General Settings:
If you have no backend, the best option to host a static site is through Azure Storage:
https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website

I had the same problem. I solved it by using the flag --html to define explicitly the runtime according to the documentation of the runtime detection. https://github.com/Azure/app-service-linux-docs/blob/master/AzWebAppUP/runtime_detection.md
So, the solution is the following line of code:
az webapp up --location westeurope --name <name> --html
N.B: I used Azure cloud shell.

Make sure you're running the command "az webapp up --location westeurope --name" from your application root, ie inside 'html-docs-hello-world' folder.

at end of az webapp command you have give run time stack
if you are using an html page then --html you must give
Ex: az webapp up --location westeurope --name az204samplewebapphtml1 --html

To overcome this error you will need to:
cd {directory}
pip freeze > requirements.txt
The file does not need to have anything just needs to exist as azure looks for the files presence when running the deployment

Related

Enable Health Check in a app service via CLI

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.

Azure Function Error: "Your function app does not support remote build..."

When I try to deploy an Azure Function to the cloud using... func azure functionapp publish appName --build remote --publish-local-settings
...I receive the following error
Getting site publishing info...
Remote build is a new feature added to function apps.
Your function app appName does not support remote build as it was created before August 1st, 2019.
Please use '--build local' or '--build-native-deps'.
For more information, please visit https://aka.ms/remotebuild
EVEN THOUGH THE APP WAS LITERALLY JUST CREATED IN AZURE PORTAL.
System:
- Running VS Code on Ubuntu 18.04
Steps to reproduce:
Create a new Function App (and support resources) using az cli
Python runtime
Consumption plan
StandardV2 Storage plan
AppInsights
Create new Function (scaffolding) using VS Code Azure Functions extension
Create __init__.py and configure local.settings.json
Open a terminal; cd to Function folder
Run func azure functionapp publish appName --build remote --publish-local-settings
Fails everytime with the message above
Tried so far:
- Substituting --build local.
- Looks like it wants to work, but fails with error
There was an error restoring dependencies. ERROR: cannot install cryptography-2.9.2 dependency: binary dependencies without wheels are not supported when building locally. Use the "--build remote" option to build dependencies on the Azure Functions build server, or "--build-native-deps" option to automatically build and configure the dependencies using a Docker container. More information at https://aka.ms/func-python-publish
Not going to try:
- --build-local-deps because I don't want a docker instance for my Function App
Please advise. This is painful at this point.
In my case, I was provisioning an azurerm_linux_function_app with terraform and got this error. The error turned out to be caused by me forgetting to specify the storage_account_access_key setting. The docs even mention
One of storage_account_access_key or storage_uses_managed_identity must be specified when using storage_account_name.
But terraform does not actually check that when applying your configuration, resulting in a cryptic error message much later in the process.
Here is what was found today:
I initially created the Function App Storage Account with...
# Create a Function App Storage Account
az storage account create \
--name $fa_storage_name \
--resource-group $rg_name \
--access-tier Cool \
--default-action Deny \
--kind StorageV2 \
--subscription $az_sub
--location $az_loc \
--sku Standard_LRS
Changed this to...
# Create a Function App Storage Account
az storage account create \
--name $fa_storage_name \
--resource-group $rg_name \
--location $az_loc \
--sku Standard_LRS
...and was able to get past that error. The way I stumbled onto this was using the --buld local flag. It gave me a MUCH MORE ACCURATE error. Something along the lines of Check your storage account dude.
(thank you Marcelo!)

Not able to create a python function in azure

I'm not able to create the azure function in python which can be used to run python script on PowerApps.
I've tried it on command prompt and also on a visual studio in the app got created but I was not able to deploy it.
Is it possible to automate the execution of a Python script using Microsoft Flow?
I'm using this link to create the azure function
(.env) C:\Users\PAhire2\MyFunctionProj>az functionapp create --resource-group myResourceGroup --os-type Windows --consumption-plan-location westeurope --runtime python --name NewApp --storage-account 1234store
usage error: Currently supported runtimes (--runtime) in windows function apps are: dotnet, node, java, powershell.
This is the error message I'm getting
You get this error cause the python function only could be created on the Linux OS on Azure, so just change your os-type to Linux, it will be success.
az functionapp create --resource-group mygroup --os-type Linux --consumption-plan-location westeurope --runtime python --name pythonfunctiontest --storage-account mystorageaccount
I test with Azure Cloud Shell and it works. Hope this could help you. Also you could refer to the tutorial:Create a function app in Azure.

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