Misc/Initialize-NavxBuildHelper.ps1

<#
.SYNOPSIS
Configuration of the default behavior of the system
.DESCRIPTION
Defines key vault and other information
.PARAMETER tenant
Azure tenant the key vault and apps are stored in
.PARAMETER subscription
Azure subscription the key vault and apps are stored in
.PARAMETER keyVault
Name of the key vault to use to get license and other functionality
.PARAMETER publisher
Name of the default publisher to get the license from the key vault and storage context
.EXAMPLE
Initialize-NavxBuildHelper -tenant "(guid)" -subscription "test" -keyVault "test key vault" -publisher "publisher of apps"
#>

function Initialize-NavxBuildHelper {
    Param(
        [Parameter(Mandatory=$false)]
        [string] $tenant = "",
        [Parameter(Mandatory=$false)]
        [string] $subscription = "",
        [Parameter(Mandatory=$false)]
        [string] $keyVault = "",
        [Parameter(Mandatory=$false)]
        [string] $storageAccount = "",
        [Parameter(Mandatory=$false)]
        [string] $storageContainer = "",
        [Parameter(Mandatory=$false)]
        [string] $storageRelativePath = "{repository}/{version}/",
        [Parameter(Mandatory=$false)]
        [string] $storageRelativePathClient = "{repository}/{project}/{version}/}",
        [Parameter(Mandatory=$false)]
        [string] $storageAccountExternalApps = "",
        [Parameter(Mandatory=$false)]
        [string] $storageContainerExternalApps = "",
        [Parameter(Mandatory=$false)]
        [string] $storageRelativePathExternalApps = "",
        [Parameter(Mandatory=$false)]
        [string] $publisher = "",
        [Parameter(Mandatory=$false)]
        [string] $prefix = ""
    )

    $settings = Import-Config
    $ConfigPath = (Join-Path $PSScriptRoot "..\NavxBuildHelper-Config.psd1")

    if (Test-Path $ConfigPath) {
        Remove-Item $ConfigPath -Force | Out-Null
    }

    if ($tenant -ne "") {
        $settings.tenant = $tenant
    }
    if ($subscription -ne "") {
        $settings.subscription = $subscription
    }
    if ($keyVault -ne "") {
        $settings.keyVault = $keyVault
    }
    if ($storageAccount -ne "") {
        $settings.storageAccount = $storageAccount
    }
    if ($storageContainer -ne "") {
        $settings.storageContainer = $storageContainer
    }
    if ($storageRelativePath -ne "") {
        $settings.storageRelativePath = $storageRelativePath
    }
    if ($storageRelativePathClient -ne "") {
        $settings.storageRelativePathClient = $storageRelativePathClient
    }
    if ($storageAccountExternalApps -ne "") {
        $settings.storageAccountExternalApps = $storageAccountExternalApps
    }
    if ($storageContainerExternalApps -ne "") {
        $settings.storageContainerExternalApps = $storageContainerExternalApps
    }
    if ($storageRelativePathExternalApps -ne "") {
        $settings.storageRelativePathExternalApps = $storageRelativePathExternalApps
    }
    if ($publisher -ne "") {
        $settings.publisher = $publisher
    }
    if ($prefix -ne "") {
        $settings.prefix = $prefix
    }

    Add-Content $ConfigPath "@{"
    $settings.keys | ForEach-Object { Add-Content $ConfigPath " $_ = '$($settings.$_)'" }
    Add-Content $ConfigPath "}"
} Export-ModuleMember Initialize-NavxBuildHelper