Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
This gist prepares Azure for use with Packer.
param (
[string]$azurelocation = 'Australia Southeast',
[string]$app_password = 'P@ssw0rd',
$azuresub = Get-AzureRmSubscription -SubscriptionId $subscription_ID
New-AzureRmResourceGroup -Name vagrant -Location $azurelocation -Tag @{Name='vagrant'} -Verbose
$azurestorage = New-AzureRmStorageAccount -ResourceGroupName vagrant -Name vagrant$(Get-Random) -SkuName Standard_GRS -Location $azurelocation -Tags @{Name='vagrant'} -Verbose
New-AzureRmADApplication -DisplayName vagrant -HomePage -IdentifierUris -Password $app_password -Verbose
$app = Get-AzureRmADApplication -IdentifierUri -Verbose
New-AzureRmADServicePrincipal -ApplicationId $app.ApplicationId -Verbose
Start-Sleep -Seconds 10
$roleassignment = New-AzureRmRoleAssignment -ServicePrincipalName -RoleDefinitionName Owner -Scope /subscriptions/31d39423-6438-4cd9-a203-052634635dd2 -Verbose
$result = @{SubscriptionID="$($azuresub.SubscriptionId)"; TenantID = "$($azuresub.TenantId)"; ClientID = "$($app.ApplicationId)"; client_secret = $app_password; resource_group_name = 'vagrant'; storage_account = "$($azurestorage.StorageAccountName)"; object_id = "$($roleassignment.ObjectId)"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.