-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Configure Run From Package in ARM templates
- Loading branch information
Showing
6 changed files
with
108 additions
and
105 deletions.
There are no files selected for viewing
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
161 changes: 82 additions & 79 deletions
161
Solutions/Marain.Tenancy.Deployment/Marain-PostDeploy.ps1
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,87 @@ | ||
<# | ||
.EXAMPLE | ||
.\deploy.ps1 ` | ||
-Prefix "mar" ` | ||
-AppName "tenancy" ` | ||
-Environment "dev" ` | ||
-FunctionsMsDeployPackagePath "..\Marain.Tenancy.Host.Functions\bin\Release\package\Marain.Tenancy.Host.Functions.zip" | ||
This is called during Marain.Instance infrastructure deployment after the Marain-ArmDeploy.ps | ||
script. It is our opportunity to do any deployment work that needs to happen after Azure resources | ||
have been deployed. | ||
#> | ||
|
||
[CmdletBinding(DefaultParametersetName='None')] | ||
param( | ||
[string] $Prefix = "mar", | ||
[string] $AppName = "tenancy", | ||
[ValidateLength(3,12)] | ||
[string] $Suffix = "dev", | ||
[string] $FunctionsMsDeployPackagePath = "..\Marain.Tenancy.Host.Functions\bin\Release\package\Marain.Tenancy.Host.Functions.zip", | ||
[string] $ResourceGroupLocation = "northeurope", | ||
[string] $ArtifactStagingDirectory = ".", | ||
[string] $ArtifactStorageContainerName = "stageartifacts", | ||
[switch] $IsDeveloperEnvironment, | ||
[switch] $UpdateLocalConfigFiles, | ||
[switch] $SkipDeployment | ||
) | ||
|
||
Begin{ | ||
# Setup options and variables | ||
$ErrorActionPreference = 'Stop' | ||
Set-Location $PSScriptRoot | ||
|
||
$Suffix = $Suffix.ToLower() | ||
$AppName = $AppName.ToLower() | ||
$Prefix = $Prefix.ToLower() | ||
|
||
$ResourceGroupName = $Prefix + "." + $AppName.ToLower() + "." + $Suffix | ||
$DefaultName = $Prefix + $AppName.ToLower() + $Suffix | ||
|
||
$ArtifactStorageResourceGroupName = $ResourceGroupName + ".artifacts"; | ||
$ArtifactStorageAccountName = $Prefix + $AppName + $Suffix + "ar" | ||
$ArtifactStagingDirectory = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $ArtifactStagingDirectory)) | ||
|
||
$FunctionsMsDeployPackageFolderName = "MsDeploy"; | ||
|
||
$FunctionsAppPackageFileName = [System.IO.Path]::GetFileName($FunctionsMsDeployPackagePath) | ||
|
||
$CosmosDbName = $DefaultName | ||
$KeyVaultName = $DefaultName | ||
} | ||
|
||
Process{ | ||
|
||
#.\Scripts\Grant-CurrentAadUserKeyVaultSecretAccess ` | ||
# -ResourceGroupName $ResourceGroupName ` | ||
# -KeyVaultName $KeyVaultName | ||
|
||
.\Scripts\Add-CosmosAccessKeyToKeyVault ` | ||
-ResourceGroupName $ResourceGroupName ` | ||
-KeyVaultName $KeyVaultName ` | ||
-CosmosDbName $CosmosDbName ` | ||
-SecretName 'tenancystorecosmosdbkey' | ||
|
||
Write-Host 'Grant the function access to the KV' | ||
|
||
$FunctionAppName = $Prefix + $AppName.ToLower() + $Suffix | ||
|
||
.\Scripts\Grant-KeyVaultSecretGetToMsi ` | ||
-ResourceGroupName $ResourceGroupName ` | ||
-KeyVaultName $KeyVaultName ` | ||
-AppName $FunctionAppName | ||
|
||
Write-Host 'Revoking KV secret access to current user' | ||
|
||
.\Scripts\Revoke-CurrentAadUserKeyVaultSecretAccess ` | ||
-ResourceGroupName $ResourceGroupName ` | ||
-KeyVaultName $KeyVaultName | ||
} | ||
|
||
End{ | ||
Write-Host -ForegroundColor Green "`n######################################################################`n" | ||
Write-Host -ForegroundColor Green "Deployment finished" | ||
Write-Host -ForegroundColor Green "`n######################################################################`n" | ||
# Marain.Instance expects us to define just this one function. | ||
Function MarainDeployment([MarainServiceDeploymentContext] $ServiceDeploymentContext) { | ||
|
||
$ServiceDeploymentContext.UploadReleaseAssetAsAppServiceSitePackage( | ||
"Marain.Tenancy.Host.Functions.zip", | ||
$ServiceDeploymentContext.AppName | ||
) | ||
|
||
# [CmdletBinding(DefaultParametersetName='None')] | ||
# param( | ||
# [string] $Prefix = "mar", | ||
# [string] $AppName = "tenancy", | ||
# [ValidateLength(3,12)] | ||
# [string] $Suffix = "dev", | ||
# [string] $FunctionsMsDeployPackagePath = "..\Marain.Tenancy.Host.Functions\bin\Release\package\Marain.Tenancy.Host.Functions.zip", | ||
# [string] $ResourceGroupLocation = "northeurope", | ||
# [string] $ArtifactStagingDirectory = ".", | ||
# [string] $ArtifactStorageContainerName = "stageartifacts", | ||
# [switch] $IsDeveloperEnvironment, | ||
# [switch] $UpdateLocalConfigFiles, | ||
# [switch] $SkipDeployment | ||
# ) | ||
|
||
# Begin{ | ||
# # Setup options and variables | ||
# $ErrorActionPreference = 'Stop' | ||
# Set-Location $PSScriptRoot | ||
|
||
# $Suffix = $Suffix.ToLower() | ||
# $AppName = $AppName.ToLower() | ||
# $Prefix = $Prefix.ToLower() | ||
|
||
# $ResourceGroupName = $Prefix + "." + $AppName.ToLower() + "." + $Suffix | ||
# $DefaultName = $Prefix + $AppName.ToLower() + $Suffix | ||
|
||
# $ArtifactStorageResourceGroupName = $ResourceGroupName + ".artifacts"; | ||
# $ArtifactStorageAccountName = $Prefix + $AppName + $Suffix + "ar" | ||
# $ArtifactStagingDirectory = [System.IO.Path]::GetFullPath([System.IO.Path]::Combine($PSScriptRoot, $ArtifactStagingDirectory)) | ||
|
||
# $FunctionsMsDeployPackageFolderName = "MsDeploy"; | ||
|
||
# $FunctionsAppPackageFileName = [System.IO.Path]::GetFileName($FunctionsMsDeployPackagePath) | ||
|
||
# $CosmosDbName = $DefaultName | ||
# $KeyVaultName = $DefaultName | ||
# } | ||
|
||
# Process{ | ||
|
||
# #.\Scripts\Grant-CurrentAadUserKeyVaultSecretAccess ` | ||
# # -ResourceGroupName $ResourceGroupName ` | ||
# # -KeyVaultName $KeyVaultName | ||
|
||
# .\Scripts\Add-CosmosAccessKeyToKeyVault ` | ||
# -ResourceGroupName $ResourceGroupName ` | ||
# -KeyVaultName $KeyVaultName ` | ||
# -CosmosDbName $CosmosDbName ` | ||
# -SecretName 'tenancystorecosmosdbkey' | ||
|
||
# Write-Host 'Grant the function access to the KV' | ||
|
||
# $FunctionAppName = $Prefix + $AppName.ToLower() + $Suffix | ||
|
||
# .\Scripts\Grant-KeyVaultSecretGetToMsi ` | ||
# -ResourceGroupName $ResourceGroupName ` | ||
# -KeyVaultName $KeyVaultName ` | ||
# -AppName $FunctionAppName | ||
|
||
# Write-Host 'Revoking KV secret access to current user' | ||
|
||
# .\Scripts\Revoke-CurrentAadUserKeyVaultSecretAccess ` | ||
# -ResourceGroupName $ResourceGroupName ` | ||
# -KeyVaultName $KeyVaultName | ||
# } | ||
|
||
# End{ | ||
# Write-Host -ForegroundColor Green "`n######################################################################`n" | ||
# Write-Host -ForegroundColor Green "Deployment finished" | ||
# Write-Host -ForegroundColor Green "`n######################################################################`n" | ||
} | ||
|
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
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
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
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