Skip to content

Commit

Permalink
Merge pull request #2772 from sebassem/main
Browse files Browse the repository at this point in the history
fix: add dynamic powershell modules installation for Agora
  • Loading branch information
sebassem authored Oct 15, 2024
2 parents eeec05b + 1c491a4 commit 1c24a81
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,12 @@

# PowerShell modules
PowerShellModules = @(
'Az.ConnectedKubernetes',
'Az.KubernetesConfiguration',
'Az.Kusto',
'Az.EventGrid',
'Az.Storage',
'Az.EventHub'
@{name='Az.ConnectedKubernetes'; version="0.10.3"},
@{name='Az.KubernetesConfiguration'; version="latest"},
@{name='Az.Kusto'; version="latest"},
@{name='Az.EventGrid'; version="latest"},
@{name='Az.Storage'; version="latest"},
@{name='Az.EventHub'; version="latest"}
)

# Chocolatey packages list
Expand Down
6 changes: 3 additions & 3 deletions azure_jumpstart_ag/artifacts/PowerShell/AgConfig-retail.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@

# PowerShell modules
PowerShellModules = @(
'Az.ConnectedKubernetes'
'Az.KubernetesConfiguration'
'Az.Kusto'
@{name='Az.ConnectedKubernetes'; version="0.10.3"},
@{name='Az.KubernetesConfiguration'; version="latest"},
@{name='Az.Kusto'; version="latest"}
)

# Chocolatey packages list
Expand Down
15 changes: 13 additions & 2 deletions azure_jumpstart_ag/artifacts/PowerShell/Modules/common.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,21 @@ function Deploy-AzPowerShell {
Connect-AzAccount -Credential $psCred -TenantId $Env:spnTenantId -ServicePrincipal -Subscription $subscriptionId | Out-File -Append -FilePath ($AgConfig.AgDirectories["AgLogsDir"] + "\AzPowerShell.log")
Set-AzContext -Subscription $subscriptionId
# Install PowerShell modules
# Making module install dynamic
if ($AgConfig.PowerShellModules.Count -ne 0) {
Write-Host "[$(Get-Date -Format t)] INFO: Installing PowerShell modules: " ($AgConfig.PowerShellModules -join ', ') -ForegroundColor Gray
Write-Host "[$(Get-Date -Format t)] INFO: Installing PowerShell modules" -ForegroundColor Gray
foreach ($module in $AgConfig.PowerShellModules) {
Install-Module -Name $module -Force | Out-File -Append -FilePath ($AgConfig.AgDirectories["AgLogsDir"] + "\AzPowerShell.log")
$moduleName = $module.name
$moduleVersion = $module.version
if ($moduleVersion -ne "latest" -and $null -ne $moduleVersion) {
# Install extension with specific version
Install-Module $moduleName -Repository PSGallery -Force -AllowClobber -ErrorAction Stop -RequiredVersion $moduleVersion
Write-Host "Installed $moduleName version $moduleVersion"
} else {
# Install extension without specifying a version
Install-Module -Name $moduleName -Force
Write-Host "Installed $moduleName (latest version)"
}
}
}

Expand Down

0 comments on commit 1c24a81

Please sign in to comment.