Azure / azure-dev

A developer CLI that reduces the time it takes for you to get started on Azure. The Azure Developer CLI (azd) provides a set of developer-friendly commands that map to key stages in your workflow - code, build, deploy, monitor, repeat.
https://aka.ms/azd
MIT License
385 stars 176 forks source link

AZD hangs in WSL2 when running init --template #3583

Open khowling opened 3 months ago

khowling commented 3 months ago

Output from azd version azd version 1.7.0 (commit 49d6adc2efb178083f61822e6b4715258560803d)

Describe the bug Running azd init --template webapp-mysql-dbjohn0isaac/flask-webapp-mysql-db , shows this output, and never returns a prompt or error (same for multiple different templates)

Initializing an app to run on Azure (azd init)

  |   ====| Downloading template code to: /home/xxxxxx/test/azd01

This is the same as issue : #460 , but that has been closed

Also, running azd to get the help screen, it says the command syntax is azd init --template [template name]. Running azd template list the Name is different from the Repository Path. I'm assuming you are not expecting the Name on the init command line?

To Reproduce as above

Expected behavior expect to either work, or return a error message

Environment WIndows 11, running in WSL2 using Ubuntu.

khowling commented 3 months ago

More information:

As azd template list returns a long list! many linux users will pipe to grep to look for terms like python or appservice etc. Because you are returning a url formatted output, this appears to effect the output of grep. Thus I was putting in a none existing template url.

To reproduce: azd template list | grep python

this returns:

Microservices App - Dapr Bindings Cron Python ACA PostgreSQL                                   Awesome AZD  python-cron-postgresAzure-Samples/bindings-dapr-python-cron-postgres
Azure Functions - LangChain with Azure OpenAI and ChatGPT (Python v2 Function)                 Awesome AZD  python-ai-langchainAzure-Samples/function-python-ai-langchain
Azure Functions - Chat using ChatGPT (Python v2 Function)                                      Awesome AZD  python-ai-openai-chatgptAzure-Samples/function-python-ai-openai-chatgpt

Then running this Hangs, because the repo is not found

azd init --template python-cron-postgresAzure-Samples/bindings-dapr-python-cron-postgres

Suggested fixes for usability

rajeshkamal5050 commented 3 months ago

Looks like the clickable url links and its name/description is causing some issue on linux when grepping.

Seems to be working fine on mac.

azd template list | grep python-mongo-aca Containerized React Web App with Python API and MongoDB Awesome AZD Azure-Samples/todo-python-mongo-aca

on linux,

azd template list | grep python-mongo-aca Containerized React Web App with Python API and MongoDB Awesome AZD python-mongo-acaAzure-Samples/todo-python-mongo-aca

@weikanglim @vhvb1989 have you seen this?

vhvb1989 commented 3 months ago

@khowling , there might be a few alternatives for what you are doing.

1) azd built-in filter: When you run azd init and choose select a template, azd has a built-in filter that helps you to pick a template. Just type for searching, like:

image

You wouldn't need to run azd templates first for picking a template.

2) When you run azd templates, you can change the output to Json file, azd templates -o json. It might be easier to pipe and grep the output that way, as you can target the field you need, like azd template list -o json | grep -Po 'repositoryPath": "(.*python.*)"'