This is the code for the wheatstalk/azure-powershell-core-az Docker image. This image is built from mcr.microsoft.com/powershell
and includes working Az.*
PowerShell modules, kubectl
, and helm
. This image can be used to test Azure-controlling PowerShell scripts, especially those that combine ARM with Azure Kubernetes Service boilerplate. (Hence kubectl and helm.)
You may run scripts by mounting the script files as volumes. For example:
docker run --rm -it -v somepath:/sut wheatstalk/azure-powershell-core-az:latest -- pwsh /sut/script.ps1
You may connect to Azure as a service principal with this image. For example, given $ClientId
, $ClientSecret
, $SubscriptionId
, and $TenantId
, the following lines in a script file will provide an authenticated PowerShell session:
$secureClientSecret = ConvertTo-SecureString $ClientSecret -AsPlainText -Force
$credentials = New-Object System.Management.Automation.PSCredential ($ClientId, $secureClientSecret)
Connect-AzAccount -ServicePrincipal -Credential $credentials -Subscription $SubscriptionId -Tenant $TenantId
# Test the Azure context.
Get-AzContext