-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathentrypoint.ps1
54 lines (41 loc) · 1.4 KB
/
entrypoint.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
Param(
[string]
[Parameter(Mandatory=$true)]
$ResourceGroupName,
[string]
[Parameter(Mandatory=$true)]
$AppName,
[string]
[Parameter(Mandatory=$false)]
$Reset = "false",
[string]
[Parameter(Mandatory=$false)]
$SubscriptionId = ""
)
$clientId = ($env:AZURE_CREDENTIALS | ConvertFrom-Json).clientId
$clientSecret = ($env:AZURE_CREDENTIALS | ConvertFrom-Json).clientSecret | ConvertTo-SecureString -AsPlainText -Force
$tenantId = ($env:AZURE_CREDENTIALS | ConvertFrom-Json).tenantId
$credentials = New-Object System.Management.Automation.PSCredential($clientId, $clientSecret)
$connected = Connect-AzAccount -ServicePrincipal -Credential $credentials -Tenant $tenantId
if (-not [string]::IsNullOrWhiteSpace($SubscriptionId)) {
Set-AzContext -Subscription $SubscriptionId
}
$profile = ""
if ([System.Convert]::ToBoolean($Reset) -eq $true) {
$profile = Reset-AzWebAppPublishingProfile `
-ResourceGroupName $ResourceGroupName `
-Name $AppName
$profile = ""
} else {
$profile = Get-AzWebAppPublishingProfile `
-ResourceGroupName $ResourceGroupName `
-Name $AppName
$profile = $profile.Replace("`r", "").Replace("`n", "")
}
Write-Output "::set-output name=profile::$profile"
Remove-Variable profile
Remove-Variable connected
Remove-Variable credentials
Remove-Variable tenantId
Remove-Variable clientSecret
Remove-Variable clientId