WARNING: The provided service principal secret will be included in the 'AzureRmContext.json' file

Copper Contributor

How do I fix the below?   Thsi is windows server 2019 and I added everyone with full control permissions to .\Azure.

 

VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\PackageManagement.psd1'.
VERBOSE: Loading 'FormatsToProcess' from path 'C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\PackageManagement.format.ps1xml'.
VERBOSE: Loading module from path 'C:\Program
Files\WindowsPowerShell\Modules\PackageManagement\1.0.0.1\Microsoft.PowerShell.PackageManagement.dll'.
VERBOSE: Exporting cmdlet 'Find-Package'.
VERBOSE: Exporting cmdlet 'Get-Package'.
VERBOSE: Exporting cmdlet 'Get-PackageProvider'.
VERBOSE: Exporting cmdlet 'Get-PackageSource'.
VERBOSE: Exporting cmdlet 'Install-Package'.
VERBOSE: Exporting cmdlet 'Import-PackageProvider'.
VERBOSE: Exporting cmdlet 'Find-PackageProvider'.
VERBOSE: Exporting cmdlet 'Install-PackageProvider'.
VERBOSE: Exporting cmdlet 'Register-PackageSource'.
VERBOSE: Exporting cmdlet 'Save-Package'.
VERBOSE: Exporting cmdlet 'Set-PackageSource'.
VERBOSE: Exporting cmdlet 'Uninstall-Package'.
VERBOSE: Exporting cmdlet 'Unregister-PackageSource'.
VERBOSE: Importing cmdlet 'Find-Package'.
VERBOSE: Importing cmdlet 'Find-PackageProvider'.
VERBOSE: Importing cmdlet 'Get-Package'.
VERBOSE: Importing cmdlet 'Get-PackageProvider'.
VERBOSE: Importing cmdlet 'Get-PackageSource'.
VERBOSE: Importing cmdlet 'Import-PackageProvider'.
VERBOSE: Importing cmdlet 'Install-Package'.
VERBOSE: Importing cmdlet 'Install-PackageProvider'.
VERBOSE: Importing cmdlet 'Register-PackageSource'.
VERBOSE: Importing cmdlet 'Save-Package'.
VERBOSE: Importing cmdlet 'Set-PackageSource'.
VERBOSE: Importing cmdlet 'Uninstall-Package'.
VERBOSE: Importing cmdlet 'Unregister-PackageSource'.
WARNING: The provided service principal secret will be included in the 'AzureRmContext.json' file found in the user
profile ( C:\Users\username01\.Azure ). Please ensure that this directory has appropriate protections.
Connect-AzAccount : The provided account XXXXXXXXXXXXXXXXXXX does not have access to subscription ID
"XXXXXXXXXXXXXXXXXXXXXXX". Please try logging in with different credentials or a different subscription
ID.
At C:\Packages\Application01\Publish-Application01.ps1:577 char:9
+     if (Connect-AzAccount -Environment AzureXXXXXXXXX -ServicePrin ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : CloseError: (:) [Connect-AzAccount], PSInvalidOperationException
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand


dsk

 

1 Reply

@DK wrote:

I added everyone with full control permissions to .\Azure.

 


That is pretty much the opposite of the meaning of the Warning:


@DK wrote:

WARNING: The provided service principal secret will be included in the 'AzureRmContext.json' file found in the user
profile ( C:\Users\username01\.Azure ). Please ensure that this directory has appropriate protections.

You are apparently connecting to Azure with Connect-AzAccount using a Service Principal. The Secret (which equals to a password) is getting saved as plaintext in the user's profile. If you add Everyone with Full Control permissions to that folder, you are not protecting it. Just make sure that no other users can access that folder. The default user profile permissions should be sufficient for that.

You can disable the saving of credentials for this PowerShell session using 

 

Disable-AzContextAutosave -Scope Process

 

or just 

 

Disable-AzContextAutosave​

to disable it for the current user.