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

%3CLINGO-SUB%20id%3D%22lingo-sub-1717807%22%20slang%3D%22en-US%22%3EWARNING%3A%20The%20provided%20service%20principal%20secret%20will%20be%20included%20in%20the%20'AzureRmContext.json'%20file%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1717807%22%20slang%3D%22en-US%22%3E%3CP%3EHow%20do%20I%20fix%20the%20below%3F%26nbsp%3B%20%26nbsp%3BThsi%20is%20windows%20server%202019%20and%20I%20added%20everyone%20with%20full%20control%20permissions%20to%20.%5CAzure.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EVERBOSE%3A%20Loading%20module%20from%20path%20'C%3A%5CProgram%3CBR%20%2F%3EFiles%5CWindowsPowerShell%5CModules%5CPackageManagement%5C1.0.0.1%5CPackageManagement.psd1'.%3CBR%20%2F%3EVERBOSE%3A%20Loading%20'FormatsToProcess'%20from%20path%20'C%3A%5CProgram%3CBR%20%2F%3EFiles%5CWindowsPowerShell%5CModules%5CPackageManagement%5C1.0.0.1%5CPackageManagement.format.ps1xml'.%3CBR%20%2F%3EVERBOSE%3A%20Loading%20module%20from%20path%20'C%3A%5CProgram%3CBR%20%2F%3EFiles%5CWindowsPowerShell%5CModules%5CPackageManagement%5C1.0.0.1%5CMicrosoft.PowerShell.PackageManagement.dll'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Find-Package'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Get-Package'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Get-PackageProvider'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Get-PackageSource'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Install-Package'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Import-PackageProvider'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Find-PackageProvider'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Install-PackageProvider'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Register-PackageSource'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Save-Package'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Set-PackageSource'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Uninstall-Package'.%3CBR%20%2F%3EVERBOSE%3A%20Exporting%20cmdlet%20'Unregister-PackageSource'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Find-Package'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Find-PackageProvider'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Get-Package'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Get-PackageProvider'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Get-PackageSource'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Import-PackageProvider'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Install-Package'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Install-PackageProvider'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Register-PackageSource'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Save-Package'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Set-PackageSource'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Uninstall-Package'.%3CBR%20%2F%3EVERBOSE%3A%20Importing%20cmdlet%20'Unregister-PackageSource'.%3CBR%20%2F%3EWARNING%3A%20The%20provided%20service%20principal%20secret%20will%20be%20included%20in%20the%20'AzureRmContext.json'%20file%20found%20in%20the%20user%3CBR%20%2F%3Eprofile%20(%20C%3A%5CUsers%5Cusername01%5C.Azure%20).%20Please%20ensure%20that%20this%20directory%20has%20appropriate%20protections.%3CBR%20%2F%3EConnect-AzAccount%20%3A%20The%20provided%20account%20XXXXXXXXXXXXXXXXXXX%20does%20not%20have%20access%20to%20subscription%20ID%3CBR%20%2F%3E%22XXXXXXXXXXXXXXXXXXXXXXX%22.%20Please%20try%20logging%20in%20with%20different%20credentials%20or%20a%20different%20subscription%3CBR%20%2F%3EID.%3CBR%20%2F%3EAt%20C%3A%5CPackages%5CApplication01%5CPublish-Application01.ps1%3A577%20char%3A9%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3Bif%20(Connect-AzAccount%20-Environment%20AzureXXXXXXXXX%20-ServicePrin%20...%3CBR%20%2F%3E%2B%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%2B%20CategoryInfo%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%26nbsp%3B%20%3A%20CloseError%3A%20(%3A)%20%5BConnect-AzAccount%5D%2C%20PSInvalidOperationException%3CBR%20%2F%3E%26nbsp%3B%20%26nbsp%3B%20%2B%20FullyQualifiedErrorId%20%3A%20Microsoft.Azure.Commands.Profile.ConnectAzureRmAccountCommand%3C%2FP%3E%3CHR%20%2F%3E%3CP%3Edsk%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1717807%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3Epowershell%20script%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Occasional 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.