Service Principles

I used the following Powershell commands to setup a session using a service principle. I also had to give the SP the Reader role over the scope over the subscription.

$appId = "xxxx"
$clientSecret = $env:appsecret
$securePassword = ConvertTo-SecureString -String $clientSecret -AsPlainText -Force
$tenantId = "xxxx"
$subscriptionId = "xxxx"
$credential = New-Object -TypeName System.Management.Automation.PSCredential $appId, $securePassword
Connect-AzAccount -ServicePrincipal -TenantId $tenantId -SubscriptionId $subscriptionId -Credential $credential