I'm trying to build a Github codespace that'll install the Azure CLI by default.
In my devcontainer.json file I have the Azure Tools and Azure CLI Tools extension and I can access Azure from these extensions.
However, in my terminal I can't seem to access the az cli. I just get a "bash: az: command not found" error.
I can manually install Azure CLI each time by running this each time I spin up a new codespace.
sudo su root
curl -L https://aka.ms/InstallAzureCli | sudo bash
This is my devcontainer.json file
{
"name": ".NET in Codespaces",
"image": "mcr.microsoft.com/dotnet/sdk:8.0",
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {
"version": "2"
},
"ghcr.io/devcontainers/features/powershell:1": {
"version": "latest"
},
"ghcr.io/azure/azure-dev/azd:0": {
"version": "latest"
},
"ghcr.io/devcontainers/features/common-utils:2": {},
"ghcr.io/devcontainers/features/dotnet:2": {
"version": "none",
"dotnetRuntimeVersions": "7.0",
"aspNetCoreRuntimeVersions": "7.0"
}
},
"customizations": {
"vscode": {
"extensions": [
"ms-vscode.vscode-node-azure-pack",
"GitHub.copilot",
"GitHub.vscode-github-actions",
"ms-dotnettools.vscode-dotnet-runtime",
"ms-dotnettools.csdevkit",
"ms-dotnetools.csharp",
"ms-vscode.azurecli"
]
}
},
"forwardPorts": [
8080,
8081
],
"postCreateCommand": "cd ./SampleApp && dotnet restore",
"hostRequirements": {
"memory": "8gb",
"cpus": 4
},
"remoteEnv": {
"DOTNET_MULTILEVEL_LOOKUP": "0",
"TARGET": "net8.0"
},
"portsAttributes": {
"8080": {
"label": "Weather API",
"onAutoForward": "notify"
},
"8081": {
"label": "Weather Front End",
"onAutoForward": "notify"
}
}
}
What do I need to change in order for the codespace to install azure cli each time?
This is my repo if that helps at all (the only thing I've changed is the devcontainer.json file) https://github.com/waiholiu/dotnet-codespace-withazurecli
Looks like you already fixed this but sharing the solution for others coming across this post.
There is an Azure CLI DevContainer Feature that you can use in addition to the ones you already have.