Skip to content

Commit

Permalink
improve environment variables structure
Browse files Browse the repository at this point in the history
  • Loading branch information
FH-Inway committed Oct 3, 2024
1 parent 2edeb7b commit f457edd
Showing 1 changed file with 25 additions and 20 deletions.
45 changes: 25 additions & 20 deletions d365fo.tools/internal/scripts/variables.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -36,56 +36,61 @@ $Script:MRConfigFile = 'C:\FinancialReporting\Server\ApplicationService\bin\MRSe
#Update all module variables
Update-ModuleVariables

# Environment variables
$environment = Get-ApplicationEnvironment

$Script:AOSPath = $environment.Aos.AppRoot
$Script:TenantId = $environment.Aad.TenantDomainGUID

$dataAccess = $environment.DataAccess
$aos = $environment.Aos
$Script:AOSPath = $aos.AppRoot
$Script:PackageDirectory = $aos.PackageDirectory
$Script:MetaDataDir = $aos.MetadataDirectory

$dataAccess = $environment.DataAccess
$Script:DatabaseServer = $dataAccess.DbServer

$Script:DatabaseName = $dataAccess.Database
$Script:DatabaseUserName = $dataAccess.SqlUser
$Script:DatabaseUserPassword = $dataAccess.SqlPwd

$Script:BinDir = $environment.Common.BinDir

$Script:PackageDirectory = $environment.Aos.PackageDirectory

$Script:MetaDataDir = $environment.Aos.MetadataDirectory

$Script:BinDirTools = $environment.Common.DevToolsBinDir
$common = $environment.Common
$Script:BinDir = $common.BinDir
$Script:BinDirTools = $common.DevToolsBinDir
$Script:IsOnebox = $common.IsOneboxEnvironment

$Script:ServerRole = [ServerRole]::Unknown
$RoleVaule = $(If ($environment.Monitoring.MARole -eq "" -or $environment.Monitoring.MARole -eq "dev") { "Development" } Else { $environment.Monitoring.MARole })

$RoleVaule = $(
If ($environment.Monitoring.MARole -eq "" -or $environment.Monitoring.MARole -eq "dev") {
"Development"
} Else {
$environment.Monitoring.MARole
}
)
if ($null -ne $RoleVaule) {
$Script:ServerRole = [ServerRole][Enum]::Parse([type]"ServerRole", $RoleVaule, $true);
}

$infrastructure = $environment.Infrastructure
$Script:EnvironmentType = [EnvironmentType]::Unknown
$Script:CanUseTrustedConnection = $false
if ($environment.Infrastructure.HostName -like "*cloud.onebox.dynamics.com*") {
if ($infrastructure.HostName -like "*cloud.onebox.dynamics.com*") {
$Script:EnvironmentType = [EnvironmentType]::LocalHostedTier1
$Script:CanUseTrustedConnection = $true
}
elseif ($environment.Infrastructure.HostName -match "(cloudax|axcloud).*dynamics.com") {
elseif ($infrastructure.HostName -match "(cloudax|axcloud).*dynamics.com") {
$Script:EnvironmentType = [EnvironmentType]::AzureHostedTier1
$Script:CanUseTrustedConnection = $true
}
elseif ($environment.Infrastructure.HostName -like "*sandbox.ax.dynamics.com*") {
elseif ($infrastructure.HostName -like "*sandbox.ax.dynamics.com*") {
$Script:EnvironmentType = [EnvironmentType]::MSHostedTier1
$Script:CanUseTrustedConnection = $true
}
elseif ($environment.Infrastructure.HostName -like "*sandbox.operations.*dynamics.com*") {
elseif ($infrastructure.HostName -like "*sandbox.operations.*dynamics.com*") {
$Script:EnvironmentType = [EnvironmentType]::MSHostedTier2
}
$Script:Url = $infrastructure.HostUrl

$Script:Url = $environment.Infrastructure.HostUrl
$Script:DatabaseUserName = $dataAccess.SqlUser
$Script:DatabaseUserPassword = $dataAccess.SqlPwd
$Script:Company = "DAT"

$Script:IsOnebox = $environment.Common.IsOneboxEnvironment

$RegSplat = @{
Path = "HKLM:\SOFTWARE\Microsoft\Dynamics\Deployment\"
Expand Down

0 comments on commit f457edd

Please sign in to comment.