Skip to content

corrected devcontainer to work on arm64 computers#28939

Merged
dolauli merged 7 commits intoAzure:mainfrom
RenSilvaAU:resilv/devcontainer
Jan 27, 2026
Merged

corrected devcontainer to work on arm64 computers#28939
dolauli merged 7 commits intoAzure:mainfrom
RenSilvaAU:resilv/devcontainer

Conversation

@RenSilvaAU
Copy link
Contributor

@RenSilvaAU RenSilvaAU commented Nov 26, 2025

Description

Updated devcontainer configuration for Azure PowerShell development

The configuration includes:

  • Custom Dockerfile based on .NET 8.0 SDK (amd64 platform)
  • GitHub CLI and Node.js LTS features
  • Post-create script that installs AutoRest, platyPS, and Az.Accounts modules
  • C# extension pre-configured for the container
  • Root user access for PowerShell script execution

Mandatory Checklist

  • SHOULD update ChangeLog.md file(s) appropriately
    • Update src/{{SERVICE}}/{{SERVICE}}/ChangeLog.md.
      • A snippet outlining the change(s) made in the PR should be written under the ## Upcoming Release header in the past tense. not the case
    • Should not change ChangeLog.md if no new release is required, such as fixing test case only.
  • SHOULD regenerate markdown help files if there is cmdlet API change. [Instruction] (../blob/main/documentation/development-docs/help-generation.md#updating-all-markdown-files-in-a-module) not the case
  • SHOULD have proper test coverage for changes in pull request. not the case
  • SHOULD NOT adjust version of module manually in pull request not the case

Copilot AI review requested due to automatic review settings November 26, 2025 22:46
@azure-client-tools-bot-prd
Copy link

Thanks for your contribution! The pull request validation has started. Please revisit this comment for updated status.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to improve the devcontainer configuration for Azure PowerShell development by creating a custom Dockerfile and moving setup commands from inline to a dedicated post-create script. However, there is a critical issue: the PR title claims to enable ARM64 support, but the Dockerfile explicitly forces AMD64 architecture, which will cause emulation overhead on ARM64 machines rather than native support.

Key Changes:

  • Introduces custom Dockerfile with explicit platform specification
  • Moves setup commands to a dedicated post-create.sh script
  • Adds additional PowerShell module installations (Az.Accounts)

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
.devcontainer/Dockerfile Creates custom Dockerfile that forces AMD64 platform (contradicts PR goal of ARM64 support)
.devcontainer/post-create.sh Extracts setup commands into dedicated script; installs npm, AutoRest, platyPS, and Az.Accounts
.devcontainer/devcontainer.json Updates to use custom Dockerfile and post-create script instead of inline command

You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings November 26, 2025 22:57
@RenSilvaAU
Copy link
Contributor Author

@dolauli ,

Isolated change for devcontainer, as suggesed in previous PR

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.


You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.

@RenSilvaAU RenSilvaAU marked this pull request as ready for review November 26, 2025 23:27
@wyunchi-ms
Copy link
Contributor

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copilot AI review requested due to automatic review settings January 27, 2026 00:23
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 6 comments.

@@ -0,0 +1,18 @@
#!/bin/bash
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The post-create.sh script should be marked as executable in the git repository. While devcontainer implementations typically handle this automatically, it's best practice to ensure the script has execute permissions committed to the repository.

You can verify and set this with:
chmod +x .devcontainer/post-create.sh
git add .devcontainer/post-create.sh

This ensures the script will be executable when cloned or when Docker builds the container.

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +7
echo "� Updating npm..."
npm update -g npm

echo "�📦 Installing AutoRest..."
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The echo statements on lines 4 and 7 contain malformed emoji characters that appear as "�" and "�📦". This suggests an encoding issue during file creation or editing.

These should be corrected to use proper UTF-8 encoded emojis or replaced with plain text for better compatibility. For example:

  • Line 4: "🔄 Updating npm..." or "Updating npm..."
  • Line 7: "📦 Installing AutoRest..." or "Installing AutoRest..."
Suggested change
echo " Updating npm..."
npm update -g npm
echo "📦 Installing AutoRest..."
echo "🔄 Updating npm..."
npm update -g npm
echo "📦 Installing AutoRest..."

Copilot uses AI. Check for mistakes.
Comment on lines +5 to +7
# Set working directory
WORKDIR /workspace

Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The working directory is set to /workspace, but the devcontainer.json mounts the workspace at /workspaces/${localWorkspaceFolderBasename} (note the plural "workspaces"). This mismatch means the WORKDIR directive has no practical effect since the actual workspace will be mounted at a different location.

Consider either:

  1. Removing this WORKDIR directive as it's not needed (the devcontainer will automatically set the working directory to the mounted workspace), or
  2. Changing it to match the actual mount point if you need to ensure consistency
Suggested change
# Set working directory
WORKDIR /workspace

Copilot uses AI. Check for mistakes.
Comment on lines +7 to +9

# Set default user to root for pwsh compatibility
USER root
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The USER root directive is redundant here because the base image mcr.microsoft.com/devcontainers/dotnet:1-8.0 already runs as a non-root user by default, and the devcontainer.json explicitly sets "remoteUser": "root" on line 47, which will override any USER directive in the Dockerfile.

This line can be safely removed as it has no effect given the devcontainer.json configuration.

Suggested change
# Set default user to root for pwsh compatibility
USER root

Copilot uses AI. Check for mistakes.
Comment on lines +11 to +17
pwsh -c "Install-Module -Name platyPS -Force -Scope CurrentUser"

echo "🔐 Installing Az.Accounts for authentication..."
pwsh -c "Install-Module -Name Az.Accounts -Force -Scope CurrentUser"

echo "🧪 Installing PSScriptAnalyzer for static analysis..."
pwsh -c "Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser"
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script installs PowerShell modules with -Scope CurrentUser, but since the devcontainer runs as root user (as configured in devcontainer.json line 47), these modules will be installed in the root user's profile. This is appropriate for a containerized development environment, but note that if the remoteUser configuration changes in the future, these modules would need to be reinstalled.

This is acceptable for the current configuration, but consider adding a comment in the script explaining this design choice for future maintainers.

Copilot uses AI. Check for mistakes.

echo "🧪 Installing PSScriptAnalyzer for static analysis..."
pwsh -c "Install-Module -Name PSScriptAnalyzer -Force -Scope CurrentUser"

Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script is missing the PowerShell execution policy configuration that is listed as a prerequisite in the repository's development documentation. While execution policies are primarily a Windows concern and Linux/macOS PowerShell has fewer restrictions by default, it's good practice to explicitly set this to ensure consistent behavior across environments.

Consider adding this line after the PSScriptAnalyzer installation:

echo "⚙️ Setting PowerShell execution policy..."
pwsh -c "Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -Force"

This aligns with the prerequisites documented in documentation/development-docs/azure-powershell-developer-guide.md lines 57-60.

Suggested change
echo "⚙️ Setting PowerShell execution policy..."
pwsh -c "Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser -Force"

Copilot uses AI. Check for mistakes.
Copilot AI review requested due to automatic review settings January 27, 2026 00:44
@isra-fel
Copy link
Member

/azp run

@azure-pipelines
Copy link
Contributor

Azure Pipelines successfully started running 3 pipeline(s).

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

#!/usr/bin/env pwsh
#Requires -Version 7.0

$ErrorActionPreference = "Stop"
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script uses Set-StrictMode is missing, which is a PowerShell best practice for catching errors early. According to the coding guidelines for PowerShell scripts in this repository, scripts should include Set-StrictMode -Version 2.0 (or higher) for better error catching.

Add Set-StrictMode -Version 2.0 after the ErrorActionPreference setting.

Suggested change
$ErrorActionPreference = "Stop"
$ErrorActionPreference = "Stop"
Set-StrictMode -Version 2.0

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +15
Write-Host "📦 Updating npm..." -ForegroundColor Cyan
npm update -g npm
if ($LASTEXITCODE -ne 0) {
throw "Failed to update npm"
}

Write-Host "🚀 Installing AutoRest..." -ForegroundColor Cyan
npm install -g autorest
if ($LASTEXITCODE -ne 0) {
throw "Failed to install AutoRest"
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script includes proper error handling with $ErrorActionPreference = "Stop", try-catch blocks for exit codes, and -ErrorAction Stop for PowerShell cmdlets. However, the npm update and npm install commands could fail in non-obvious ways. Consider adding informative error messages that include troubleshooting hints, such as checking network connectivity or npm installation.

For example, wrap the npm operations in a try-catch that provides more context about common failure scenarios.

Suggested change
Write-Host "📦 Updating npm..." -ForegroundColor Cyan
npm update -g npm
if ($LASTEXITCODE -ne 0) {
throw "Failed to update npm"
}
Write-Host "🚀 Installing AutoRest..." -ForegroundColor Cyan
npm install -g autorest
if ($LASTEXITCODE -ne 0) {
throw "Failed to install AutoRest"
try {
Write-Host "📦 Updating npm..." -ForegroundColor Cyan
npm update -g npm
if ($LASTEXITCODE -ne 0) {
throw "npm update failed with exit code $LASTEXITCODE"
}
Write-Host "🚀 Installing AutoRest..." -ForegroundColor Cyan
npm install -g autorest
if ($LASTEXITCODE -ne 0) {
throw "AutoRest installation failed with exit code $LASTEXITCODE"
}
} catch {
Write-Error "npm tooling setup failed: $($_.Exception.Message)"
Write-Error ("Troubleshooting tips:`n" +
" - Verify that Node.js and npm are installed and on the PATH (run 'npm --version').`n" +
" - Check your network connectivity and any proxy/firewall settings that might block npm.`n" +
" - If behind a proxy, configure npm to use it (e.g. 'npm config set proxy <url>').`n" +
" - Retry this script after addressing the above issues.")
exit 1

Copilot uses AI. Check for mistakes.
"remoteUser": "root",

// Mount optimization for macOS
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=cached"
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The workspaceMount uses the deprecated "consistency" option with value "cached". Docker Desktop for Mac deprecated the consistency flags (cached, delegated, consistent) in favor of automatic optimization. Modern versions of Docker Desktop ignore these flags, and they have no effect on Linux or Windows.

This option can be safely removed from the workspaceMount configuration as it no longer provides any benefit and may cause warnings in newer Docker versions.

Suggested change
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind,consistency=cached"
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/${localWorkspaceFolderBasename},type=bind"

Copilot uses AI. Check for mistakes.
@RenSilvaAU
Copy link
Contributor Author

@wyunchi-ms , @dolauli ,

As requested, I have:

  • isolated the devcontainer changes in this PR
  • changed post-create script to ps1

@wyunchi-ms
Copy link
Contributor

LGTM

@dolauli dolauli merged commit e16d6a4 into Azure:main Jan 27, 2026
17 of 18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants