Skip to content

Commit c7ef06c

Browse files
authored
Enhance sqlpackage-extract.md with PowerShell example (#10283)
Added PowerShell script example for authentication using a service principal.
1 parent 19bf046 commit c7ef06c

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

docs/tools/sqlpackage/sqlpackage-extract.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,13 @@ SqlPackage /Action:Extract /TargetFile:"C:\AdventureWorksLT.dacpac" /UniversalAu
6161
```
6262

6363
```powershell
64+
$ClientId = "<app-registration-client-id>"
65+
$ClientSecret = "<client-secret>"
66+
67+
# Convert the service principal client secret into a SecureString and create a PSCredential object for authentication.
68+
$SecureSecret = ConvertTo-SecureString $ClientSecret -AsPlainText -Force
69+
$Credential = New-Object System.Management.Automation.PSCredential($ClientId, $SecureSecret)
70+
6471
# example extract to create a schema-only .dacpac file connecting using an access token associated with a service principal
6572
$Account = Connect-AzAccount -ServicePrincipal -Tenant $Tenant -Credential $Credential
6673
$AccessToken_Object = (Get-AzAccessToken -Account $Account -Resource "https://database.windows.net/")

0 commit comments

Comments
 (0)