scripts/misc/New-OsProjectGlobals.ps1
# # New-OsProjectGlobals # ## Description # Deploys Azure resources used globally by a project that are not specific to a particular environment. # These are one time resource deployments, which is why this is done via PowerShell. # ## Installed Resources # * Project Resource Group # * Project Key Vault # * Project storage account # ## Future Improvements # * Better error handling of resource naming conventions for resource creation. # ## Bugs/Issues Function New-OsProjectGlobals { Param( [alias('Dir', 'Path')] [string] $ProjectDirectory = (Get-Location | Select-Object -ExpandProperty Path).ToString(), [alias('P')] [validateset('ATMOS', 'livepush', '360', 'intrepid', 'exp', 'INTR')] [string] $Project, [string] $StorageAccountName, [string] $prefix = 'spze2', [string] $azureRegion = "eastus2" ) $ResourceGroupName = ($prefix + '-' + $project + '-Project').toUpper() if (-not $project) { $envJson = Get-Content "$ProjectDirectory\global.parameters.json" | ConvertFrom-Json $project = $envJson.parameters.Global.value.AppName } if (!$StorageAccountName) { $StorageAccountName = ($prefix + $project + 'project').ToLower() } try { New-AzResourceGroup -Name $ResourceGroupName -Location $azureRegion -ErrorAction Stop } Catch { Write-Warning "There is already a resource group with this name!" } try { New-AzKeyVault -VaultName ($prefix + '-' + $project + '-KV').toUpper() -ResourceGroupName $ResourceGroupName -Location $azureRegion -ErrorAction Stop } Catch { Write-Warning "There is already a key vault with this name!" } } |