Azure FunctionsをDevcontainerで実行するまでの調査
以下二つのサイトを参考に進めていました。
https://qiita.com/takoraisutaro/items/cc29fc17c4eb496d5129
https://blog.shibayan.jp/entry/20231003/1696320617
しかし、エラーが出て実行できませんでした。
エラーの内容を取るのを忘れてしまいましたが、調査した感じM1 MACで発生するエラーのようでした。azure functions core toolsがArm64上のPython関数をサポートしていないようです。
回避策もあるようなので、いくつかのサイトを確認しながら調査しました。 以下を確認しながら作業していきます。
https://jimbobbennett.dev/blogs/azure-functions-python-m1/
以下二つにチェックを入れます。
Use Virtualzation framework
Use Rosetta for x86_64/amd64 emulation on Apple Silicon
コンテナーで開いてみます。
ローカルでdevcontainer.jsonを編集を押してエラーを確認します。
ログ
> [dev_containers_target_stage 5/5] RUN --mount=type=bind,from=dev_containers_feature_content_source,source=azure-functions-core-tools_0,target=/tmp/build-features-src/azure-functions-core-tools_0 cp -ar /tmp/build-features-src/azure-functions-core-tools_0 /tmp/dev-container-features && chmod -R 0755 /tmp/dev-container-features/azure-functi
[2024-03-24T01:21:04.199Z] ons-core-tools_0 && cd /tmp/dev-container-features/azure-functions-core-tools_0 && chmod +x ./devcontainer-features-install.sh && ./devcontainer-features-install.sh && rm -rf /tmp/dev-container-features/azure-functions-core-tools_0:
0.111 ===========================================================================
0.111 Feature : Azure Functions Core Tools
0.111 Description : Installs the Azure Functions Core Tools along with needed dependencies. Useful for developing Azure Function apps inside codespaces.
[2024-03-24T01:21:04.199Z] 0.111 Id : ghcr.io/jlaundry/devcontainer-features/azure-functions-core-tools
0.111 Version : 1.0.0
0.111 Documentation : https://github.com/devcontainers/features/tree/main/src/azure-functions-core-tools
0.111 Options :
0.111 VERSION="latest"
0.111 ===========================================================================
0.124 (*) Installing Azure Functions Core Tools...
0.949 MICROSOFT_GPG_KEYS_URI=https://packages.microsoft.com/keys/microsoft.asc
1.178 Get:1 http://deb.debian.org/debian bullseye InRelease [116 kB]
1.232 Get:2 https://packages.microsoft.com/debian/11/prod bullseye InRelease [3650 B]
1.252 Get:3 https://dl.yarnpkg.com/debian stable InRelease [17.1 kB]
1.283 Get:4 https://packages.microsoft.com/debian/11/prod bullseye/main arm64 Packages [30.6 kB]
1.305 Get:5 https://packages.microsoft.com/debian/11/prod bullseye/main all Packages [1214 B]
1.449 Get:6 http://deb.debian.org/debian-security bullseye-security InRelease [48.4 kB]
1.458 Get:7 http://deb.de
[2024-03-24T01:21:04.200Z] bian.org/debian bullseye-updates InRelease [44.1 kB]
1.469 Get:8 http://deb.debian.org/debian bullseye/main arm64 Packages [7957 kB]
1.537 Get:9 https://dl.yarnpkg.com/debian stable/main all Packages [10.9 kB]
1.620 Get:10 http://deb.debian.org/debian-security bullseye-security/main arm64 Packages [266 kB]
1.627 Get:11 http://deb.debian.org/debian bullseye-updates/main arm64 Packages [16.3 kB]
1.774 Get:12 https://dl.yarnpkg.com/debian stable/main arm64 Packages [10.9 kB]
2.273 Fetched 8521 kB in 1s (7304 kB/s)
2.273 Reading package lists...
2.563 Reading package lists...
2.837 Building dependency tree...
2.910 Reading state information...
2.954 E: Unable to locate package azure-functions-core-tools
2.955 ERROR: Feature "Azure Functions Core Tools" (ghcr.io/jlaundry/devcontainer-features/azure-functions-core-tools) failed to install! Look at the documentation at https://github.com/devcontainers/features/tree/main/src/azure-functions-core-tools for help troubleshooting this error.
------
[2024-03-24T01:21:04.201Z] Dockerfile.extended:24
--------------------
23 |
24 | >>> RUN --mount=type=bind,from=dev_containers_feature_content_source,source=azure-functions-core-tools_0,target=/tmp/build-features-src/azure-functions-core-tools_0
25 | >>> cp -ar /tmp/build-features-src/azure-functions-core-tools_0 /tmp/dev-container-features
26 | >>> && chmod -R 0755 /tmp/dev-container-features/azure-functions-core-tools_0
27 | >>> && cd /tmp/dev-container-features/azure-functions-core-tools_0
28 | >>> && chmod +x ./devcontainer-features-install.sh
29 | >>> && ./devcontainer-features-install.sh
30 | >>> && rm -rf /tmp/dev-container-features/azure-functions-core-tools_0
31 |
--------------------
ERROR: failed to solve: process "/bin/sh -c cp -ar /tmp/build-features-src/azure-functions-core-tools_0 /tmp/dev-container-features && chmod -R 0755 /tmp/dev-container-features/azure-functions-core-tools_0 && cd /tmp/dev-container-features/azure-functions-core-tools_0 && chmod +x ./d
[2024-03-24T01:21:04.202Z] evcontainer-features-install.sh && ./devcontainer-features-install.sh && rm -rf /tmp/dev-container-features/azure-functions-core-tools_0" did not complete successfully: exit code: 1
[2024-03-24T01:21:04.205Z] Stop (4977 ms): Run: docker buildx build --load --build-context dev_containers_feature_content_source=/var/folders/dw/_p3b_71d3s31399dg60vv9340000gn/T/devcontainercli/container-features/0.56.2-1711243257523 --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/devcontainers/python:1-3.12-bullseye --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp --target dev_containers_target_stage -t vsc-azfunc-ad3295fb9b5c321bb2c1aca766472bd9e753d719b0c5709d17d3c40dbb89ae77-features -f /var/folders/dw/_p3b_71d3s31399dg60vv9340000gn/T/devcontainercli/container-features/0.56.2-1711243257523/Dockerfile.extended /Users/takumi/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/empty-folder
[2024-03-24T01:21:04.205Z] Error: Command failed: docker buildx build --load --build-context dev_containers_feature_content_source=/var/folders/dw/_p3b_71d3s31399dg60vv9340000gn/T/devcontainercli/container-features/0.56.2-1711243257523 --build-arg _DEV_CONTAINERS_BASE_IMAGE=mcr.microsoft.com/devcontainers/python:1-3.12-bullseye --build-arg _DEV_CONTAINERS_IMAGE_USER=root --build-arg _DEV_CONTAINERS_FEATURE_CONTENT_SOURCE=dev_container_feature_content_temp --target dev_containers_target_stage -t vsc-azfunc-ad3295fb9b5c321bb2c1aca766472bd9e753d719b0c5709d17d3c40dbb89ae77-features -f /var/folders/dw/_p3b_71d3s31399dg60vv9340000gn/T/devcontainercli/container-features/0.56.2-1711243257523/Dockerfile.extended /Users/takumi/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/data/empty-folder
[2024-03-24T01:21:04.206Z] at atA (/Users/takumi/.vscode/extensions/ms-vscode-remote.remote-containers-0.348.0/dist/spec-node/devContainersSpecCLI.js:464:1260)
[2024-03-24T01:21:04.206Z] at yH (/Users/takumi/.vscode/extensions/ms-vscode-remote.remote-containers-0.348.0/dist/spec-node/devContainersSpecCLI.js:464:1002)
[2024-03-24T01:21:04.206Z] at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
[2024-03-24T01:21:04.206Z] at async StA (/Users/takumi/.vscode/extensions/ms-vscode-remote.remote-containers-0.348.0/dist/spec-node/devContainersSpecCLI.js:481:3660)
[2024-03-24T01:21:04.206Z] at async ZC (/Users/takumi/.vscode/extensions/ms-vscode-remote.remote-containers-0.348.0/dist/spec-node/devContainersSpecCLI.js:481:4775)
[2024-03-24T01:21:04.206Z] at async trA (/Users/takumi/.vscode/extensions/ms-vscode-remote.remote-containers-0.348.0/dist/spec-node/devContainersSpecCLI.js:614:11269)
[2024-03-24T01:21:04.206Z] at async erA (/Users/takumi/.vscode/extensions/ms-vscode-remote.remote-containers-0.348.0/dist/spec-node/devContainersSpecCLI.js:614:11010)
[2024-03-24T01:21:04.208Z] Stop (7073 ms): Run: /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Users/takumi/.vscode/extensions/ms-vscode-remote.remote-containers-0.348.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /Users/takumi/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-59f361d3-3148-4467-a244-7d09d14f62e11711243256291 --workspace-folder /Users/takumi/Documents/src/private_src/devcontainer/azfunc --workspace-mount-consistency cached --id-label devcontainer.local_folder=/Users/takumi/Documents/src/private_src/devcontainer/azfunc --id-label devcontainer.config_file=/Users/takumi/Documents/src/private_src/devcontainer/azfunc/.devcontainer/devcontainer.json --log-level debug --log-format json --config /Users/takumi/Documents/src/private_src/devcontainer/azfunc/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root
[2024-03-24T01:21:04.208Z] Exit code 1
[2024-03-24T01:21:04.209Z] Command failed: /Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin) /Users/takumi/.vscode/extensions/ms-vscode-remote.remote-containers-0.348.0/dist/spec-node/devContainersSpecCLI.js up --user-data-folder /Users/takumi/Library/Application Support/Code/User/globalStorage/ms-vscode-remote.remote-containers/data --container-session-data-folder /tmp/devcontainers-59f361d3-3148-4467-a244-7d09d14f62e11711243256291 --workspace-folder /Users/takumi/Documents/src/private_src/devcontainer/azfunc --workspace-mount-consistency cached --id-label devcontainer.local_folder=/Users/takumi/Documents/src/private_src/devcontainer/azfunc --id-label devcontainer.config_file=/Users/takumi/Documents/src/private_src/devcontainer/azfunc/.devcontainer/devcontainer.json --log-level debug --log-format json --config /Users/takumi/Documents/src/private_src/devcontainer/azfunc/.devcontainer/devcontainer.json --default-user-env-probe loginInteractiveShell --mount type=volume,source=vscode,target=/vscode,external=true --skip-post-create --update-remote-user-uid-default on --mount-workspace-git-root
[2024-03-24T01:21:04.209Z] Exit code 1
2.955 ERROR: Feature "Azure Functions Core Tools" (ghcr.io/jlaundry/devcontainer-features/azure-functions-core-tools) failed to install! Look at the documentation at https://github.com/devcontainers/features/tree/main/src/azure-functions-core-tools for help troubleshooting this error.
冒頭のログを確認して、現在amdで実行されているかを確認するとarmで実行されているようだった。
[2024-03-24T01:20:56.679Z] Client:
Cloud integration: v1.0.35+desktop.11
Version: 25.0.3
API version: 1.44
Go version: go1.21.6
Git commit: 4debf41
Built: Tue Feb 6 21:13:26 2024
OS/Arch: darwin/arm64
Context: desktop-linux
Server: Docker Desktop 4.28.0 (139021)
Engine:
Version: 25.0.3
API version: 1.44 (minimum version 1.24)
Go version: go1.21.6
Git commit: f417435
Built: Tue Feb 6 21:14:22 2024
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.6.28
GitCommit: ae07eda36dd25f8a1b98dfbf587313b99c0190bb
runc:
Version: 1.1.12
GitCommit: v1.1.12-0-g51d5e94
docker-init:
Version: 0.19.0
GitCommit: de40ad0
なので、別のテンプレートを使ってみます。
しばやんさんのテンプレートを使ってみます。
https://github.com/shibayan/devcontainers?tab=readme-ov-file
ここで明示的に
platform: linux/amd64
と指定してあるので、これならRosettaが効いてarmの対応ができるのではないかと考えています。
しかし、うまくいかず。うまくいかずというのは語弊があるかもしれない。ちょっと不安定というのが正しい。
例えば、本来拡張仕事に最適化されたファイル表示になるはずが、全てプレーンなファイルのような見た目になる。
上記の拡張機能の問題については別の話だったので別記事にまとめます。
ディスカッション
コメント一覧
まだ、コメントがありません