error - WARNING: The version '1.9.4' of module 'Az.Accounts' is currently in use. Powershell script

%3CLINGO-SUB%20id%3D%22lingo-sub-1716665%22%20slang%3D%22en-US%22%3Eerror%20-%20WARNING%3A%20The%20version%20'1.9.4'%20of%20module%20'Az.Accounts'%20is%20currently%20in%20use.%20Powershell%20script%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1716665%22%20slang%3D%22en-US%22%3E%3CP%3EPS%20C%3A%5CApplication01%26gt%3BInstall-Module%20-Name%20Az%20-AllowClobber%20-Scope%20AllUsers%3C%2FP%3E%3CP%3EPS%20C%3A%5CApplication01%26gt%3BConnect-AzAccount%20%23%23%23%20this%20prompts%20me%20for%20my%20azure%20logon%3C%2FP%3E%3CP%3EPS%20C%3A%5CApplication01%26gt%3BUpdate-Module%20-Name%20Az%3C%2FP%3E%3CP%3EPS%20C%3A%5CApplication01%26gt%3B.%5CPublish-Application01.ps1%20-action%20%22Deploy%22%20%60%3CBR%20%2F%3E-azureAccountApplicationId%20%22a3XXXXXXXXXXXXXXXXXXXXXXXX76%22%20%60%3CBR%20%2F%3E-azureAccountPassword%20%2243XXXXXXXXXXXXXXXXXXXXXXXXXXXm%22%20%60%3CBR%20%2F%3E-package%20%22C%3A%5CApplication01%5CApplication01.server.Web.zip%22%20%60%3CBR%20%2F%3E-azureSubscriptionId%20%22c27XXXXXXXXXXXXXXXXXXXXXXXXX32%22%20%60%3CBR%20%2F%3E-azureAccountTenantId%20%2241XXXXXXXXXXXXXXXXXXXXXXXXX1d%22%20%60%3CBR%20%2F%3E-hostAdminPassword%20%22XXXXXXXXXXXX%22%20%60%3CBR%20%2F%3E-defaultTenantAdminPassword%20%22XXXXXXXXXXX%22%20%60%3CBR%20%2F%3E-resourceGroupName%20%22RG01%22%20%60%3CBR%20%2F%3E-appServiceName%20%22Applicationservice01%22%20%60%3CBR%20%2F%3E-nugetRepositoryType%20%22Composite%22%20%60%3CBR%20%2F%3E-storageType%20%22Azure%22%20%60%3CBR%20%2F%3E-storageLocation%20%22DefaultEndpointsProtocol%3Dhttps%3A%2F%2FXXXXXXXXX%22%20%60%3CBR%20%2F%3E-appSettings%20%40%7B%22Telemetry.Enabled%22%3D%22false%22%7D%20%60%3CBR%20%2F%3E-verbose%3C%2FP%3E%3CP%3EWARNING%3A%20The%20version%20'1.9.4'%20of%20module%20'Az.Accounts'%20is%20currently%20in%20use.%20Retry%20the%20operation%20after%20closing%20the%20applications.%3CBR%20%2F%3EWARNING%3A%20The%20provided%20service%20principal%20secret%20will%20be%20included%20in%20the%20'AzureRmContext.json'%20file%20found%20in%20the%20user%20profile%20(%20C%3A%5CUsers%5Czzadmin%5C.Azure%20).%20Please%20ensure%20that%20this%20directory%20has%20appropriate%20protections.%3CBR%20%2F%3EConnect-AzAccount%20%3A%20The%20provided%20account%20a3XXXXXXXXXXXXXXXXXXXX76%20does%20not%20have%20access%20to%20subscription%20ID%20%22c2XXXXXXXXXXXXXXXXXXXXXXXX2%22.%20Please%20try%20logging%20in%20with%20different%20credentials%20or%20a%20different%20subscription%20ID.%3CBR%20%2F%3EAt%20C%3A%5CApplication01%5CPublish-Application01.ps1%3A577%20char%3A9%3CBR%20%2F%3E%2B%20if%20(Connect-AzAccount%20-Environment%20AzureUSGovernment%20-ServicePrin%20...%3CBR%20%2F%3E%2B%20~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%2B%20CategoryInfo%20%3A%20CloseError%3A%20(%3A)%20%5BConnect-AzAccount%5D%2C%20PSInvalidOperationException%3CBR%20%2F%3E%2B%20FullyQualifiedErrorId%20%3A%20Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand%3C%2FP%3E%3CP%3EXXXXXXXXXXXXXXXXXX%3C%2FP%3E%3CP%3E%3CBR%20%2F%3ELine%20577%20%26gt%3B%26gt%3B%26gt%3B%20-ServicePrincipal%20--%20my%20understanding%20is%20a%20prompt%20will%20appear%20to%20enter%20a%20value%20for%20ServicePrincipal.%3C%2FP%3E%3CP%3Efunction%20AuthenticateToAzure%20%7B%3C%2FP%3E%3CP%3E%24securePassword%20%3D%20%24azureAccountPassword%20%7C%20ConvertTo-SecureString%20-AsPlainText%20-Force%3CBR%20%2F%3E%24credential%20%3D%20New-Object%20System.Management.Automation.PSCredential(%24azureAccountApplicationId%2C%20%24securePassword)%3C%2FP%3E%3CP%3Eif%20(Connect-AzAccount%20-Environment%20AzureUSGovernment%20-ServicePrincipal%20-SubscriptionId%20%24azureSubscriptionId%20-TenantId%20%24azureAccountTenantId%20-Credential%20%24credential)%7B%3CBR%20%2F%3EWrite-Host%20%22Logged%20in%20to%20Az%22%20-ForegroundColor%20Green%3CBR%20%2F%3E%7D%20else%20%7B%3CBR%20%2F%3EWrite-Error%20%22Failed%20to%20log%20in%20to%20Az%22%3CBR%20%2F%3EExit%201%3CBR%20%2F%3E%7D%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EXXXXXXXXXXXXXX%3CBR%20%2F%3EI%20have%20tried%20rebooting%20the%20VM%20and%20error%20still%20appears.%3CBR%20%2F%3EThe%20zzadmin%20account%20on%20the%20VM%20is%20a%20local%20administrator.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1716665%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EAzure%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EAzure%20IaaS%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EWindows%20PowerShell%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Highlighted
Occasional Contributor

PS C:\Application01>Install-Module -Name Az -AllowClobber -Scope AllUsers

PS C:\Application01>Connect-AzAccount ### this prompts me for my azure logon

PS C:\Application01>Update-Module -Name Az

PS C:\Application01>.\Publish-Application01.ps1 -action "Deploy" `
-azureAccountApplicationId "a3XXXXXXXXXXXXXXXXXXXXXXXX76" `
-azureAccountPassword "43XXXXXXXXXXXXXXXXXXXXXXXXXXXm" `
-package "C:\Application01\Application01.server.Web.zip" `
-azureSubscriptionId "c27XXXXXXXXXXXXXXXXXXXXXXXXX32" `
-azureAccountTenantId "41XXXXXXXXXXXXXXXXXXXXXXXXX1d" `
-hostAdminPassword "XXXXXXXXXXXX" `
-defaultTenantAdminPassword "XXXXXXXXXXX" `
-resourceGroupName "RG01" `
-appServiceName "Applicationservice01" `
-nugetRepositoryType "Composite" `
-storageType "Azure" `
-storageLocation "DefaultEndpointsProtocol=https://XXXXXXXXX" `
-appSettings @{"Telemetry.Enabled"="false"} `
-verbose

WARNING: The version '1.9.4' of module 'Az.Accounts' is currently in use. Retry the operation after closing the applications.
WARNING: The provided service principal secret will be included in the 'AzureRmContext.json' file found in the user profile ( C:\Users\zzadmin\.Azure ). Please ensure that this directory has appropriate protections.
Connect-AzAccount : The provided account a3XXXXXXXXXXXXXXXXXXXX76 does not have access to subscription ID "c2XXXXXXXXXXXXXXXXXXXXXXXX2". Please try logging in with different credentials or a different subscription ID.
At C:\Application01\Publish-Application01.ps1:577 char:9
+ if (Connect-AzAccount -Environment AzureUSGovernment -ServicePrin ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Connect-AzAccount], PSInvalidOperationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand

XXXXXXXXXXXXXXXXXX


Line 577 >>> -ServicePrincipal -- my understanding is a prompt will appear to enter a value for ServicePrincipal.

function AuthenticateToAzure {

$securePassword = $azureAccountPassword | ConvertTo-SecureString -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential($azureAccountApplicationId, $securePassword)

if (Connect-AzAccount -Environment AzureUSGovernment -ServicePrincipal -SubscriptionId $azureSubscriptionId -TenantId $azureAccountTenantId -Credential $credential){
Write-Host "Logged in to Az" -ForegroundColor Green
} else {
Write-Error "Failed to log in to Az"
Exit 1
}

 

XXXXXXXXXXXXXX
I have tried rebooting the VM and error still appears.
The zzadmin account on the VM is a local administrator.

 

0 Replies