@@ -64,8 +64,9 @@ After executing this cmdlet, you can disconnect from an Azure account using Disc
64
64
## EXAMPLES
65
65
66
66
### Example 1: Use an interactive login to connect to an Azure account
67
- ```
67
+ ``` powershell
68
68
PS C:\> Connect-AzureRmAccount
69
+
69
70
Account SubscriptionName TenantId Environment
70
71
------- ---------------- -------- -----------
71
72
[email protected] Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
@@ -76,34 +77,36 @@ To run Azure Resource Manager cmdlets with this account, you must provide Micros
76
77
If multi-factor authentication is enabled for your credentials, you must log in using the interactive option or use service principal authentication.
77
78
78
79
### Example 2: Connect to an Azure account using organizational ID credentials
79
- ```
80
+ ``` powershell
80
81
PS C:\> $Credential = Get-Credential
81
82
PS C:\> Connect-AzureRmAccount -Credential $Credential
83
+
82
84
Account SubscriptionName TenantId Environment
83
85
------- ---------------- -------- -----------
84
86
[email protected] Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
85
87
```
86
88
87
- The first command gets the user credentials, and then stores them in the $Credential variable.
89
+ The first command will prompt for user credentials (username and password) , and then stores them in the $Credential variable.
88
90
The second command connects to an Azure account using the credentials stored in $Credential.
89
91
This account authenticates with Azure Resource Manager using organizational ID credentials.
90
92
You cannot use multi-factor authentication or Microsoft account credentials to run Azure Resource Manager cmdlets with this account.
91
93
92
94
### Example 3: Connect to an Azure service principal account
93
- ```
95
+ ``` powershell
94
96
PS C:\> $Credential = Get-Credential
97
+
95
98
PS C:\> Connect-AzureRmAccount -Credential $Credential -Tenant "xxxx-xxxx-xxxx-xxxx" -ServicePrincipal
96
99
Account SubscriptionName TenantId Environment
97
100
------- ---------------- -------- -----------
98
101
xxxx-xxxx-xxxx-xxxx Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
99
102
```
100
103
101
- The first command gets the user credentials, and then stores them in the $Credential variable.
104
+ The first command gets the service principal credentials (application id and service principal secret) , and then stores them in the $Credential variable.
102
105
The second command connect to Azure using the service principal credentials stored in $Credential for the specified Tenant.
103
106
The ServicePrincipal switch parameter indicates that the account authenticates as a service principal.
104
107
105
108
### Example 4: Use an interactive login to connect to an account for a specific tenant and subscription
106
- ```
109
+ ``` powershell
107
110
PS C:\> Connect-AzureRmAccount -Tenant "xxxx-xxxx-xxxx-xxxx" -SubscriptionId "yyyy-yyyy-yyyy-yyyy"
108
111
Account SubscriptionName TenantId Environment
109
112
------- ---------------- -------- -----------
113
116
This command connects to an Azure account and configured AzureRM PowerShell to run cmdlets for the specified tenant and subscription by default.
114
117
115
118
### Example 5: Add an Account Using Managed Service Identity Login
116
- ```
119
+ ``` powershell
117
120
PS C:\> Connect-AzureRmAccount -MSI
121
+
118
122
Account SubscriptionName TenantId Environment
119
123
------- ---------------- -------- -----------
120
124
MSI@50342 Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
121
125
```
122
126
123
- This command connects using the managed service identity of the host environment (for example, if executed on a
127
+ This command connects using the managed service identity of the host environment (for example, if executed on a
124
128
VirtualMachine with an assigned Managed Service Identity, this will allow the code to login using that assigned identity)
125
129
130
+ ### Example 6: Add an account using certificates
131
+ ``` powershell
132
+ # For more information on creating a self-signed certificate
133
+ # and giving it proper permissions, please see the following:
134
+ # https://docs.microsoft.com/en-us/azure/active-directory/develop/howto-authenticate-service-principal-powershell
135
+ PS C:\> $Thumbprint = "0SZTNJ34TCCMUJ5MJZGR8XQD3S0RVHJBA33Z8ZXV"
136
+ PS C:\> $TenantId = "4cd76576-b611-43d0-8f2b-adcb139531bf"
137
+ PS C:\> $ApplicationId = "3794a65a-e4e4-493d-ac1d-f04308d712dd"
138
+ PS C:\> Connect-AzureRmAccount -CertificateThumbprint $Thumbprint -ApplicationId $ApplicationId -Tenant $TenantId -ServicePrincipal
139
+
140
+ Account SubscriptionName TenantId Environment
141
+ ------- ---------------- -------- -----------
142
+ xxxx-xxxx-xxxx-xxxx Subscription1 xxxx-xxxx-xxxx-xxxx AzureCloud
143
+
144
+ Account : 3794a65a-e4e4-493d-ac1d-f04308d712dd
145
+ SubscriptionName : MyTestSubscription
146
+ SubscriptionId : 85f0f653-1f86-4d2c-a9f1-042efc00085c
147
+ TenantId : 4cd76576-b611-43d0-8f2b-adcb139531bf
148
+ Environment : AzureCloud
149
+ ```
150
+
151
+ This command connects to an Azure account using certificate-based service principal authentication. Theservice principal used for authentication should have been created with the given certificate.
152
+
126
153
## PARAMETERS
127
154
128
155
### -AccessToken
0 commit comments