Skip to content

Commit c48106c

Browse files
committed
Update Packer SP Creation PowerShell Commands
Updates to the commands to create the Azure AD service principal to be used for authentication by Packer. Due to changes in the return of New-AzADServicePrincipal there is no longer a Secret value returned, the SP credentials must be set by using New-AzADSpCredential
1 parent 2c044a3 commit c48106c

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

articles/virtual-machines/windows/build-image-with-packer.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,14 @@ Create a service principal with [New-AzADServicePrincipal](/powershell/module/az
4242

4343
```azurepowershell
4444
$sp = New-AzADServicePrincipal -DisplayName "PackerSP$(Get-Random)"
45-
$BSTR = [System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($sp.Secret)
46-
$plainPassword = [System.Runtime.InteropServices.Marshal]::PtrToStringAuto($BSTR)
45+
$plainPassword = (New-AzADSpCredential -ObjectId $sp.Id).SecretText
4746
```
4847

4948
Then output the password and application ID.
5049

5150
```powershell
5251
$plainPassword
53-
$sp.ApplicationId
52+
$sp.AppId
5453
```
5554

5655

@@ -68,7 +67,7 @@ Create a file named *windows.json* and paste the following content. Enter your o
6867

6968
| Parameter | Where to obtain |
7069
|-------------------------------------|----------------------------------------------------|
71-
| *client_id* | View service principal ID with `$sp.applicationId` |
70+
| *client_id* | View service principal ID with `$sp.AppId` |
7271
| *client_secret* | View the auto-generated password with `$plainPassword` |
7372
| *tenant_id* | Output from `$sub.TenantId` command |
7473
| *subscription_id* | Output from `$sub.SubscriptionId` command |

0 commit comments

Comments
 (0)