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
408 stars 197 forks source link

[Issue] azd in dev container on Mac M1 - azd fails #2593

Open dfberry opened 1 year ago

dfberry commented 1 year ago

Output from azd version Run azd version and copy and paste the output here: azd version 1.1.0 (commit ea9cb12575734ee6a5f99c4d415c1a51d6f32d3e)

Describe the bug Description of issue you're seeing...

can't use azd up on Static React Web App + Functions with Node.js API and MongoDB on Azure template

To Reproduce Steps to reproduce the behavior...

  1. create dev container for typescript from microsoft
  2. install azd - which fails
  3. check dev container setting so azd is installed by default with container rebuild
  4. rebuild
  5. azd auth login succeeded on third try - something about localhost not being available
  6. use azd init with template switch
  7. rebuild again because now there is a new devcontainer
  8. azd up
  9. get error: ERROR: compiling bicep template: failed to compile bicep template: failed running bicep build: signal: segmentation fault, stdout: , stderr: qemu: uncaught target signal 11 (Segmentation fault) - core dumped
  10. I assume this is about docker + Mac M1

Expected behavior Does azd work on Mac M1?

Environment Information on your environment:

image

image

Additional context image

rajeshkamal5050 commented 1 year ago

@danieljurek @weikanglim can you try to repro this on your M1/M2's?

rajeshkamal5050 commented 1 year ago

@v-xuto can you try repro'ing this?

v-jiaodi commented 1 year ago

@v-xuto can you try repro'ing this?

@rajeshkamal5050 We can repro this issue. image

Environment:

In addition, when we reopen the todo-nodejs-mongo-swa-func with devContainer, encountered this error: image

danieljurek commented 1 year ago

Thanks for chatting @dfberry! A couple scenarios to consider here:

Run azd without installing azd on the local machine (container OK)

This scenario should work well enough today because our templates supply the .devcontainer config needed. However, the steps to accomplish this would be:

  1. git clone the template repo
  2. Open vscode against the template directory
  3. vscode will suggest reopening in the devcontainer, do that
  4. azd auth login and azd up, etc.

Those should all work in the devcontainer running in emulated x86_64 mode. I'll ensure that's the case. I wonder if our docs should be updated to make this path easier.... Also, we need to figure out if Rosetta should be installed to run containers in emulated mode.

Errors running bicep in non-emulated devcontainer mode

This is the error repro'd above by @v-jiaodi, this should be looked into as well.

danieljurek commented 1 year ago

bicep build, when running inside the x86_64 emulated docker container, reliably crashes (using both qemu and using Docker Desktop's experimental Rosetta emulation feature). Running file ~/.azd/bin/bicep shows that the binary is x86-64 so, given that the container is x86_64, this is the correct binary that azd is downloading.

We'll need to dig into what's making bicep fail when running bicep build in an emulated container. This could be an issue with bicep, dotnet which is building the bicep binary, or possibly qemu.

I also tried switching the devcontainer out of x86_64 mode into the ARM64 mode but that doesn't work because Azure Functions Core Tools aren't available on packages.microsoft.com for ARM64 of the Debian distro we are using. The azure-functions-core-tools releases page on GitHub also only shows binaries for x64 on Linux (no obvious ARM64 support).

Two avenues of further exploration for the bicep crash are:

  1. Fixing bicep (possibly involving .NET and qemu) or
  2. Getting azure-functions-core-tools building and publishing on ARM64 Linux
rajeshkamal5050 commented 11 months ago

@danieljurek is this issue still valid? Not seeing much activity here?

rajeshkamal5050 commented 9 months ago

@danieljurek https://azure.microsoft.com/en-us/updates/generally-available-azure-functions-support-on-apple-silicon-macs/

We are excited to announce that Azure Functions support on Apple Silicon Macs is now live. Update your Core Tools to the latest version (4.0.5455+) and try it out today!

danieljurek commented 9 months ago

There's not a release for arm64 linux yet so this does not work in devcontainer.

rajeshkamal5050 commented 7 months ago

There's not a release for arm64 linux yet so this does not work in devcontainer.

@danieljurek given the dependency on https://github.com/Azure/azure-functions-core-tools/issues/3112 please pull it when the dep is resolved. Moving to backlog.