Reputation: 25
I'm trying to run powershell script to create ACI in a Azure DevOps release pipeline. The pipeline also pushes the docker image to ACR.
My powershell script is:
# Write your PowerShell commands here.
Write-Host "Login with service principal"
az login --service-principal -u xxxxx-xxxx-xxxx-xxxx-xxxxx -p xxxxx.xxxxx --tenant xxxxx-xxxx-xxxx-xxxx-xxxxx
$resourceGroup = "MyResourceGroup"
$location = "southcentralus"
$containerRegistry = "MyCR"
Write-Host "Get repository content..."
az acr repository list -n $containerRegistry --output table
Write-Host "Get repository password..."
$acrPassword = az acr credential show -n $containerRegistry --query "passwords[0].value" -o tsv
$acrPassword
Write-Host "Get repository Login Server..."
$loginServer = az acr show -n $containerRegistry --query loginServer --output tsv
$loginServer
Write-Host "Set image tag..."
$imageTag = "mycr.azurecr.io/image:latest"
$imageTag
Write-Host "Set container group name..."
$containerGroupName = "dev-mycontgroup-aci"
Write-Host "Creating ACI..."
az container create -g $resourceGroup -n $containerGroupName --image $imageTag --cpu 2 --memory 4 --registry-username registryUserName --registry-password $acrPassword --os-type windows --vnet /subscriptions/xxxx-xxxx-xxxx-xxxx-xxxx/resourceGroups/Network/providers/Microsoft.Network/virtualNetworks/MyEnvironments-VNET --subnet /subscriptions/xxxx-xxxx-xxxx-xxxx-xxxx/resourceGroups/Network/providers/Microsoft.Network/virtualNetworks/MyEnvironments-VNET/subnets/MySubnet
The resource group and ACR are already created. If I run these scripts by az cli it creates the ACI but is not creating through the release pipeline and I'm always getting:
ERROR: (ServiceUnavailable) The requested resource is not available in the location 'southcentralus' at this moment. Please retry with a different resource request or in another location. Resource requested: '2' CPU '4' GB memory 'Windows Server 2019 - After 2B' OS virtual network
Even if I reduce the CPU and memory to 1 I got the same. This is a windows image for .Net Framework 4.8 using ltsc2019. I think that would be an issue also with az cli but in that way it creates the instance. Could it be possible that cli behaves different from release pipelines?
Upvotes: 1
Views: 97