-
Notifications
You must be signed in to change notification settings - Fork 0
/
Create-AzureResources.ps1
23 lines (19 loc) · 1.23 KB
/
Create-AzureResources.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
param (
[string] $AzureUserPrinciple,
[securestring] $AzureUserPrincipleSecret,
[string] $AzureTenantName,
[string] $AzureResourceGroup,
[string] $AzureApplicationName,
[string] $GitHubOrganization,
[string] $GitHubRepository
)
$PlanName = 'BasicPlan'
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $AzureUserPrinciple, $AzureUserPrincipleSecret
$LoginDetails = (az login --service-principal -u $Credential.UserName -p $Credential.GetNetworkCredential().Password --tenant $AzureTenantName) | ConvertFrom-Json
az group create -l westeurope -n $AzureResourceGroup
az appservice plan create -g $AzureResourceGroup -n $PlanName
az webapp create -g $AzureResourceGroup -p $PlanName -n $AzureApplicationName
#$PublishProfile = az webapp deployment list-publishing-profiles -n $azApplicationName -g $AzureResourceGroup
$SubscriptionId = $LoginDetails.id
$AzureCredentials = az ad sp create-for-rbac --name https://$AzureApplicationName --role contributor --scopes /subscriptions/$SubscriptionId/resourceGroups/$AzureResourceGroup --sdk-auth
.\Create-GithubSecret.ps1 -OrganizationName $GitHubOrganization -RepositoryName $GitHubRepository -SecretId 'AZURE_CREDENTIALS' -Secret $AzureCredentials