File tree Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Expand file tree Collapse file tree 2 files changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -122,15 +122,14 @@ azureuser@contoso.com Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
122
122
123
123
### Example 3: Connect to Azure using a service principal account
124
124
125
- The first command prompts for service principal credentials and stores them in the ` $Credential `
126
- variable. Enter your application ID for the username and service principal secret as the password
127
- when prompted. The second command connects the specified Azure tenant using the service principal
128
- credentials stored in the ` $Credential ` variable. The ** ServicePrincipal** switch parameter
129
- indicates that the account authenticates as a service principal.
125
+ The first command stores the service principal credentials in the ` $Credential ` variable. The second
126
+ command connects the specified Azure tenant using the service principal credentials stored in the
127
+ ` $Credential ` variable. The ** ServicePrincipal** switch parameter indicates that the account
128
+ authenticates as a service principal.
130
129
131
130
``` powershell
132
- $Credential = Get-Credential
133
- Connect-AzAccount -Credential $Credential -Tenant 'xxxx-xxxx-xxxx-xxxx' -ServicePrincipal
131
+ $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ApplicationId, $SecuredPassword
132
+ Connect-AzAccount -ServicePrincipal -TenantId $TenantId -Credential $Credential
134
133
```
135
134
136
135
``` Output
Original file line number Diff line number Diff line change @@ -122,15 +122,14 @@ azureuser@contoso.com Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
122
122
123
123
### Example 3: Connect to Azure using a service principal account
124
124
125
- The first command prompts for service principal credentials and stores them in the ` $Credential `
126
- variable. Enter your application ID for the username and service principal secret as the password
127
- when prompted. The second command connects the specified Azure tenant using the service principal
128
- credentials stored in the ` $Credential ` variable. The ** ServicePrincipal** switch parameter
129
- indicates that the account authenticates as a service principal.
125
+ The first command stores the service principal credentials in the ` $Credential ` variable. The second
126
+ command connects the specified Azure tenant using the service principal credentials stored in the
127
+ ` $Credential ` variable. The ** ServicePrincipal** switch parameter indicates that the account
128
+ authenticates as a service principal.
130
129
131
130
``` powershell
132
- $Credential = Get-Credential
133
- Connect-AzAccount -Credential $Credential -Tenant 'xxxx-xxxx-xxxx-xxxx' -ServicePrincipal
131
+ $Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $ApplicationId, $SecuredPassword
132
+ Connect-AzAccount -ServicePrincipal -TenantId $TenantId -Credential $Credential
134
133
```
135
134
136
135
``` Output
You can’t perform that action at this time.
0 commit comments