Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This gist prepares Azure for use with Packer.
param (
[string]$azurelocation = 'Australia Southeast',
[string]$app_password = 'P@ssw0rd',
[string]$subscription_ID
)
Add-AzureRmAccount
$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 http://vagrantauth.com -IdentifierUris http://vagrantauth.com -Password $app_password -Verbose
$app = Get-AzureRmADApplication -IdentifierUri http://vagrantauth.com -Verbose
New-AzureRmADServicePrincipal -ApplicationId $app.ApplicationId -Verbose
Start-Sleep -Seconds 10
$roleassignment = New-AzureRmRoleAssignment -ServicePrincipalName http://vagrantauth.com -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)"}
$result
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.