Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@darrenjrobinson
Last active January 5, 2017 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save darrenjrobinson/408ba8e6354657c0effe2e106f2a4241 to your computer and use it in GitHub Desktop.
Save darrenjrobinson/408ba8e6354657c0effe2e106f2a4241 to your computer and use it in GitHub Desktop.
# 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