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

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"

Related

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 :

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

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

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.

I get this error in windows CMD "stat: path too long for Windows" -- Azure cli

I get this error in windows CMD "stat: path too long for Windows" whenever I execute this command below in my azure cli in windows CMD.
az group deployment create -g "testacsengine" --template-file azuredeploy.json --parameters #azuredeploy.parameters.json
In windows, if you already install the Azure CLI model, you can execute the CLI command in CMD or Windows PowerShell ISE.
For the deployment of Azure template, you can just use the command az group deployment create -g "charlesTest" --template-file template.json in the directory of your template.
Or use the absolute path like this az group deployment create -g "charlesTest" --template-file D:\template.json. Of curse, you need to get authentication with the command az login first.
If you still get the error when you do this, the error must be inside your template. You should check your template correctly.
For more details about template deployment, see az group deployment create.

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