あなたはサービスプリンシパルを作成する必要があります。サービスプリンシパルを作成したら、Role-Based Access Controlを使用して特定のリソースにアクセス許可を割り当てることができます。そこから、あなたのスクリプトは対話的にログインしなくてもサービスプリンシパルとしてログインできます。
この方法の主な問題は、Azureリソースへのアクセスを許可する認証情報が含まれているため、スクリプトへのアクセスを保護することです。
このarticleは良いチュートリアルを持っている:
#First, login as yourself so you can setup the service principal
Login-AzureRmAccount
#Password doesn't have to be *your* password, but the password the script will use
$app = New-AzureRmADApplication –DisplayName "<Your script name>" –HomePage "http://localhost" –IdentifierUris "http://localhost/YourAppName" –Password "<Password>"
#Create the service principal
New-AzureRmADServicePrincipal –ApplicationId $app.ApplicationId
#Assign the Reader role to your new service principal. Other roles listed at
#https://azure.microsoft.com/en-us/documentation/articles/role-based-access-built-in-roles/
New-AzureRmRoleAssignment –RoleDefinitionName Reader –ServicePrincipalName $app.ApplicationId
$pass = ConvertTo-SecureString "<Password>" -AsPlainText –Force
#Servce principal username looks like [email protected]
#the GUID part is $app.ApplicationId and the domain part is found in the Azure portal
$cred = New-Object -TypeName pscredential –ArgumentList "<Service Principal UserName>", $pass
Login-AzureRmAccount -Credential $cred -ServicePrincipal –TenantId <TenantId>