Last active
October 7, 2021 15:52
-
-
Save musaugurlu/11f1795d6a3e6604d3d1a217c25d7f4f to your computer and use it in GitHub Desktop.
Azure Profile Script for Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Get-AZProfile { | |
[CmdletBinding()] | |
param ( | |
) | |
begin { | |
$OutputHolder = @{ | |
AzureConfigPath = "$Home\.azure"; | |
KubeConfigPath = "$Home\.kube"; | |
} | |
} | |
process { | |
if($Env:AZURE_CONFIG_DIR) { | |
$OutputHolder.AzureConfigPath = $Env:AZURE_CONFIG_DIR | |
} | |
if($Env:KUBECONFIG) { | |
$OutputHolder.KubeConfigPath = $Env:KUBECONFIG | |
} | |
} | |
end { | |
Write-Output ([PSCustomObject] $OutputHolder) | |
} | |
} | |
function Set-AZProfile { | |
[CmdletBinding()] | |
param ( | |
[Parameter(Mandatory, HelpMessage="Azure Profile Environment")] | |
[ValidateSet("dev","qa","uat","perf","default")] | |
[string] $AZEnvironment | |
) | |
begin { | |
$DevPath = "$Home/Az-Profiles/dev" | |
$QAPath = "$Home/Az-Profiles/qa" | |
$UATPath = "$Home/Az-Profiles/uat" | |
$PERFPath = "$Home/Az-Profiles/perf" | |
} | |
process { | |
switch ($AZEnvironment) { | |
"dev" { | |
$Env:AZURE_CONFIG_DIR = $DevPath | |
$Env:KUBECONFIG = "$DevPath/kubeconfig.yml" | |
} | |
"qa" { | |
$Env:AZURE_CONFIG_DIR = $QAPath | |
$Env:KUBECONFIG = "$QAPath/kubeconfig.yml" | |
} | |
"uat" { | |
$Env:AZURE_CONFIG_DIR = $UATPath | |
$Env:KUBECONFIG = "$UATPath/kubeconfig.yml" | |
} | |
"perf" { | |
$Env:AZURE_CONFIG_DIR = $PERFPath | |
$Env:KUBECONFIG = "$PERFPath/kubeconfig.yml" | |
} | |
"default" { | |
$Env:AZURE_CONFIG_DIR = $null | |
$Env:KUBECONFIG = $null | |
} | |
} | |
} | |
end { | |
Write-Host "Azure Config profile has been set to: $AZEnvironment" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment