Wednesday, January 6, 2021

Connect Azure Using Service principal

 

$tenantID = "ADTenantID"

$applicationid = "applicationidofthespn"
$key = ConvertTo-SecureString -AsPlainText "generatedkey" -Force
$pscredential = New-Object -TypeName System.Management.Automation.PSCredential($applicationid, $key)
Connect-AzAccount -ServicePrincipal -Credential $pscredential -Tenant $tenantID

 

 

Use the following  signing to USGovernment.

$applicationid = "applicationidofthespn"
$key = ConvertTo-SecureString -AsPlainText "generatedkey" -Force
$pscredential = New-Object -TypeName System.Management.Automation.PSCredential($applicationid, $key)
Connect-AzAccount -ServicePrincipal -Credential $pscredential -Tenant $tenantId -EnvironmentName AzureUSGovernment

 

No comments:

Post a Comment