function Main() {
    $utilsConsoleAppPath = "D:\home\site\wwwroot\DeployScript\UiPath.ConfigInjector\UiPath.ConfigInjector.exe"
    $configs = & $utilsConsoleAppPath "Inject"
    $appSettingsPath = "D:\home\site\wwwroot\appsettings.json"
    $configObj = $configs | ConvertFrom-Json
    if ($configObj.isUpdate -eq "false") {
        D:\home\site\wwwroot\DeployScript\Deploy-TestManager.ps1 `
            -orchestratorUrl $configObj.orchestratorUrl `
            -identityInstallationToken $configObj.identityInstallationToken `
            -identityUrl $configObj.identityUrl `
            -testManagerUrl $configObj.testManagerUrl `
            -dbConnectionString $configObj.Database__ConnectionStrings__testmanagementhub `
            -storageConnectionString $configObj.Storage__Location `
            -appInsightsInstrKey $configObj.NLog__targets__aiTarget__instrumentationKey 

       if (-not $?) {
           Write-Output "The Deploy-TestManager.ps1 command did not run successfuly."
           Exit 1
       }

        Write-Output 'Finished CLI calls.'

        Write-Output 'Begining to back up app settings file to key vault.'

        & $utilsConsoleAppPath "BackUp" $appSettingsPath

        Write-Output 'Finished backing up app settings file to key vault.'
    }
    else {
        & $utilsConsoleAppPath "Restore" $appSettingsPath
        D:\home\site\wwwroot\DeployScript\Deploy-TestManager.ps1 -UpdateFlag
    }
}


Main
