-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfigure-local-debug.ps1
85 lines (70 loc) · 2.58 KB
/
configure-local-debug.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#
# PowerShell script to enable local debugging of website and functions
# Launches
# Azure Storage Emulator - local emulator for Azure Storage
# IIS Express - web server to host the wwwroot website
# Func.exe - host for the Azure functions
#
Param(
# Set to false to run but not execute the commands for debugging
[bool]$InvokeCommands = $true
)
$invocationPath = Split-Path $MyInvocation.MyCommand.Path
function LoadConfig([string]$ConfigFilePath) {
return ConvertFrom-Json "$(get-content $ConfigFilepath)"
}
function LaunchStorageEmulator() {
Push-Location
Set-Location -Path "${env:ProgramFiles(x86)}\Microsoft SDKs\Azure\Storage Emulator"
if ($InvokeCommands) {
# Get the current status and only start if it's not running
$status = & ".\AzureStorageEmulator.exe" status
if ($status[1].Contains('True') -eq $false) {
Write-Debug "Starting Azure Storage Emulator..."
$result = & ".\AzureStorageEmulator.exe" start
}
else {
Write-Debug "Azure Storage Emulator already started - skipping..."
}
}
Pop-Location
}
function LaunchIISExpress() {
$iisExpress = "${env:ProgramFiles(x86)}\IIS Express\iisexpress.exe"
# IIS Express not happy with other methods used to generate path - this works
$physicalPath = (Get-Item -Path "$invocationPath\wwwroot").FullName
$command = "`"$iisExpress`" /path:`"$physicalPath`""
if ($InvokeCommands) {
Write-Debug "Starting IIS Express..."
cmd /c start cmd /k $command
}
}
function LaunchFuncExe() {
Push-Location
Set-Location "$invocationPath\functions"
if ($InvokeCommands) {
Write-Debug "Starting Functions Host..."
cmd /c start cmd /k "${env:APPDATA}\npm\func host start --cors http://localhost:8080"
}
Pop-Location
}
#Write-Host $invocationPath
$env:Path += "${env:APPDATA}\npm;${env:ProgramFiles}\nodejs"
$config = LoadConfig "$invocationPath\wwwroot\local-debug-config.json"
$env:AzureWebJobsStorageConnection = $config.AzureWebJobsStorage
$env:AzureWebJobsStorage = $config.AzureWebJobsStorage
$env:AzureWebJobsMailer = $config.AzureWebJobsMailer
#KeyVault Auth
$env:KVClientId = $config.KVClientId
$env:KVKey = $config.KVKey
$env:KVUri = $config.KVUri
$env:KVKeyID = $config.KVKeyID
#Write-Host $env:AzureWebJobsStorage
$env:Service_Description = $config.Service_Description
#Write-Host $env:Service_Description
$env:APPSETTING_WEBSITE_SITE_NAME = $config.WebsiteName
#Write-Host $env:APPSETTING_WEBSITE_SITE_NAME
LaunchStorageEmulator
LaunchIISExpress
Start-Sleep -Seconds 3
LaunchFuncExe