-
Notifications
You must be signed in to change notification settings - Fork 288
Add --install-extensions to install scripts + azure.foundry extension #7594
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # yaml-language-server: $schema=../extension.schema.json | ||
| id: azure.foundry | ||
| displayName: Azure Foundry Extension (Preview) | ||
| description: >- | ||
| Installs all Azure AI Foundry extensions for azd, including agents, | ||
| custom models, and fine-tuning. | ||
| version: 0.1.0-preview | ||
| capabilities: [] | ||
| dependencies: | ||
| - id: azure.ai.agents | ||
| version: latest | ||
| - id: azure.ai.models | ||
| version: latest | ||
| - id: azure.ai.finetune | ||
| version: latest |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,6 +33,10 @@ Skips verification of the downloaded file. | |
| .PARAMETER InstallShScriptUrl | ||
| (Mac/Linux only) URL to the install-azd.sh script. Default is https://aka.ms/install-azd.sh | ||
|
|
||
| .PARAMETER InstallExtensions | ||
| Comma-separated list of azd extensions to install after azd is set up. | ||
| For example: --InstallExtensions "azure.foundry" or "azure.ai.agents,azure.ai.models" | ||
|
|
||
| .EXAMPLE | ||
| powershell -ex AllSigned -c "Invoke-RestMethod 'https://aka.ms/install-azd.ps1' | Invoke-Expression" | ||
|
|
||
|
|
@@ -67,7 +71,8 @@ param( | |
| [switch] $SkipVerify, | ||
| [int] $DownloadTimeoutSeconds = 120, | ||
| [switch] $NoTelemetry, | ||
| [string] $InstallShScriptUrl = "https://aka.ms/install-azd.sh" | ||
| [string] $InstallShScriptUrl = "https://aka.ms/install-azd.sh", | ||
| [string] $InstallExtensions = "" | ||
| ) | ||
|
|
||
| function isLinuxOrMac { | ||
|
|
@@ -297,7 +302,47 @@ if (isLinuxOrMac) { | |
| $bashParameters = $params -join ' ' | ||
| Write-Verbose "Running: curl -fsSL $InstallShScriptUrl | bash -s -- $bashParameters" -Verbose:$Verbose | ||
| bash -c "curl -fsSL $InstallShScriptUrl | bash -s -- $bashParameters" | ||
| exit $LASTEXITCODE | ||
|
|
||
| if ($LASTEXITCODE -ne 0) { | ||
| exit $LASTEXITCODE | ||
| } | ||
|
|
||
| # Handle extension install on Linux/Mac after bash script completes | ||
| if ($InstallExtensions) { | ||
| Write-Host "" | ||
| Write-Host "Installing requested extensions..." | ||
|
|
||
| $azdCmd = Get-Command azd -ErrorAction SilentlyContinue | ||
| if ($azdCmd) { | ||
| $azdBin = $azdCmd.Source | ||
|
Comment on lines
+311
to
+317
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of calling azd after the bash script completes, map
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This can be done by joining if ($InstallExtensions) {
$params += "--install-extensions ${$InstallExtensions -join ','}"
} |
||
| } else { | ||
| Write-Warning "Could not locate azd after install. Extensions were not installed." | ||
| Write-Warning "Open a new terminal and run: azd extension install <extension-id>" | ||
| exit 0 | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. When Extension install failure already returns 1 (line 341). This creates an inconsistency: "extension install failed" = exit 1, but "couldn't even try" = exit 0. Consider exit 1 here since the user explicitly asked for extensions. |
||
| } | ||
|
|
||
| $installExtFailed = $false | ||
| $extensions = $InstallExtensions -split ',' | ||
| foreach ($extId in $extensions) { | ||
| $extId = $extId.Trim() | ||
| if ($extId) { | ||
| Write-Host "Installing extension: $extId" | ||
| & $azdBin extension install $extId | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Windows extension block wraps this in try/catch (line 468) but the Linux/Mac block doesn't. If |
||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Warning "Failed to install extension: $extId. You can retry later with: azd extension install $extId" | ||
| $installExtFailed = $true | ||
| } else { | ||
| Write-Host "Extension $extId installed successfully" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if ($installExtFailed) { | ||
| exit 1 | ||
| } | ||
| } | ||
|
|
||
| exit 0 | ||
| } | ||
|
|
||
| try { | ||
|
|
@@ -388,6 +433,58 @@ try { | |
| Write-Host "" | ||
| Write-Host "Read more about Azure Developer CLI telemetry: https://github.com/Azure/azure-dev#data-collection" | ||
|
|
||
| # Install extensions if requested (Windows path) | ||
| if ($InstallExtensions) { | ||
| Write-Host "" | ||
| Write-Host "Installing requested extensions..." | ||
|
|
||
| # Resolve azd binary path | ||
| # If user specified InstallFolder, use that directly. | ||
| # Otherwise, the MSI updates PATH so use Get-Command to find it. | ||
| if ($InstallFolder) { | ||
| $azdBin = Join-Path $InstallFolder "azd.exe" | ||
| } else { | ||
| # Refresh PATH from registry since MSI updated it | ||
| $machinePath = [Environment]::GetEnvironmentVariable("Path", "Machine") | ||
| $userPath = [Environment]::GetEnvironmentVariable("Path", "User") | ||
| $env:Path = "$machinePath;$userPath" | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This does mutate the current session's |
||
|
|
||
| $azdCmd = Get-Command azd -ErrorAction SilentlyContinue | ||
| if ($azdCmd) { | ||
| $azdBin = $azdCmd.Source | ||
| } else { | ||
| Write-Warning "Could not locate azd after install. Extensions were not installed." | ||
| Write-Warning "Open a new terminal and run: azd extension install <extension-id>" | ||
| exit 0 | ||
| } | ||
| } | ||
|
|
||
| $installExtFailed = $false | ||
| $extensions = $InstallExtensions -split ',' | ||
| foreach ($extId in $extensions) { | ||
| $extId = $extId.Trim() | ||
| if ($extId) { | ||
| Write-Host "Installing extension: $extId" | ||
| try { | ||
| & $azdBin extension install $extId | ||
| if ($LASTEXITCODE -ne 0) { | ||
| Write-Warning "Failed to install extension: $extId. You can retry later with: azd extension install $extId" | ||
| $installExtFailed = $true | ||
| } else { | ||
| Write-Host "Extension $extId installed successfully" | ||
| } | ||
| } catch { | ||
| Write-Warning "Failed to install extension: $extId. You can retry later with: azd extension install $extId" | ||
| $installExtFailed = $true | ||
| } | ||
| } | ||
| } | ||
|
|
||
| if ($installExtFailed) { | ||
| exit 1 | ||
| } | ||
| } | ||
|
|
||
| exit 0 | ||
| } catch { | ||
| Write-Error -ErrorRecord $_ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The invocation might look like:
PowerShell automatically interprets items separated by commas (no spaces) as an array and
[string[]]coerces to strings for later passing through to the script.