Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
# Login with your Azure Admin Account
Add-AzureRmAccount
# Create an App that will be used by the Azure Automation Function App
$app = New-AzureRmADApplication -DisplayName "Azure Automation Functions" -HomePage "https://www.mydomain.com/AAFunctions" -IdentifierUris "https://www.mydomain.com/AAFunctions" -Password "thisisntmypassword!"
# Copy the AppID to the clipboard
$applicationID = $app.ApplicationId.Guid | clip
# Create the App Service Principal
New-AzureRmADServicePrincipal -ApplicationId $app.ApplicationId
# wait for replication
Start-Sleep 15
# Assign Role DevTest Labs User which provides the ability to view everything and connect, start, restart, and shutdown virtual machines
New-AzureRmRoleAssignment -RoleDefinitionName 'DevTest Labs User' -ServicePrincipalName $app.ApplicationId
# Get the TenantID (I only have one)
$tenant = (Get-AzureRmSubscription).TenantId
$tenant
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment