@@ -51,12 +51,12 @@ internal PowerShellManager(ILogger logger)
51
51
internal void AuthenticateToAzure ( )
52
52
{
53
53
// Check if Az.Profile is available
54
- Collection < PSModuleInfo > azprofile = _pwsh . AddCommand ( "Get-Module" )
54
+ Collection < PSModuleInfo > azProfile = _pwsh . AddCommand ( "Get-Module" )
55
55
. AddParameter ( "ListAvailable" )
56
56
. AddParameter ( "Name" , "Az.Profile" )
57
57
. InvokeAndClearCommands < PSModuleInfo > ( ) ;
58
58
59
- if ( azprofile . Count == 0 )
59
+ if ( azProfile . Count == 0 )
60
60
{
61
61
_logger . Log ( LogLevel . Trace , "Required module to automatically authenticate with Azure `Az.Profile` was not found in the PSModulePath." ) ;
62
62
return ;
@@ -111,40 +111,6 @@ internal void AuthenticateToAzure()
111
111
{
112
112
_logger . Log ( LogLevel . Trace , "Skip authentication to Azure via MSI. Environment variables for authenticating to Azure are not present." ) ;
113
113
}
114
-
115
- // Try to authenticate to Azure using Service Principal
116
- string applicationId = Environment . GetEnvironmentVariable ( "SERVICE_PRINCIPAL_APP_ID" ) ;
117
- string applicationSecret = Environment . GetEnvironmentVariable ( "SERVICE_PRINCIPAL_APP_PASSWORD" ) ;
118
- string tenantId = Environment . GetEnvironmentVariable ( "SERVICE_PRINCIPAL_TENANT_ID" ) ;
119
-
120
- if ( string . IsNullOrEmpty ( applicationId ) ||
121
- string . IsNullOrEmpty ( applicationSecret ) ||
122
- string . IsNullOrEmpty ( tenantId ) )
123
- {
124
- _logger . Log ( LogLevel . Trace , "Skip authentication to Azure via Service Principal. Environment variables for authenticating to Azure are not present." ) ;
125
- return ;
126
- }
127
-
128
- // Build SecureString
129
- var secureString = new SecureString ( ) ;
130
- foreach ( char item in applicationSecret )
131
- {
132
- secureString . AppendChar ( item ) ;
133
- }
134
-
135
- using ( ExecutionTimer . Start ( _logger , "Authentication to Azure" ) )
136
- {
137
- _pwsh . AddCommand ( "Az.Profile\\ Connect-AzAccount" )
138
- . AddParameter ( "Credential" , new PSCredential ( applicationId , secureString ) )
139
- . AddParameter ( "ServicePrincipal" )
140
- . AddParameter ( "TenantId" , tenantId )
141
- . InvokeAndClearCommands ( ) ;
142
-
143
- if ( _pwsh . HadErrors )
144
- {
145
- _logger . Log ( LogLevel . Warning , "Failed to Authenticate to Azure via Service Principal. Check the logs for the errors generated." ) ;
146
- }
147
- }
148
114
}
149
115
150
116
internal void InitializeRunspace ( )
0 commit comments