Skip to content

Commit

Permalink
porting Arm template changes to stable (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjcho-msft authored May 9, 2019
1 parent 65b8446 commit e035190
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ function Install-Packages([system.collections.generic.dictionary[string,string]]
..\Deployment.Common\nuget\nuget.exe install $_ -version $version -PreRelease -Source $source -OutputDirectory $path | Out-Null
}
else {
..\Deployment.Common\nuget\nuget.exe install $_ -PreRelease -Source $source -OutputDirectory $path | Out-Null
..\Deployment.Common\nuget\nuget.exe install $_ -Source $source -OutputDirectory $path | Out-Null
}
}
}
Expand Down
42 changes: 33 additions & 9 deletions DeploymentCloud/Deployment.Common/deployResources.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@
[string]
$sslCert,

[ValidateSet("y", "n")]
[string]
$installModules,

[ValidateSet("y", "n")]
[string]
$resourceCreation,
Expand Down Expand Up @@ -123,7 +127,7 @@ function Install-Modules {

$moduleInstalled = $false
$modules.Keys | foreach {
if (!(Get-installedModule -name $_ -requiredversion $modules.Item($_) -ErrorAction SilentlyContinue )) {
if (!(Get-installedModule -name $_ -MinimumVersion $modules.Item($_) -ErrorAction SilentlyContinue )) {

Write-Host "Install Module: " $_
$moduleInstalled = $true
Expand Down Expand Up @@ -264,7 +268,6 @@ function Add-UserAppRole([string]$AppName) {
catch {}
}

# Replace token in template
# Set secret to AAD app
function Set-AzureAADAppSecret([string]$AppName) {
$app = Get-AzureRmADApplication -DisplayName $AppName
Expand All @@ -279,6 +282,18 @@ function Set-AzureAADAppSecret([string]$AppName) {
$keyValue
}

# Set credential to AAD app
function Set-AzureAADAppCert([string]$AppName) {
$app = Get-AzureRmADApplication -DisplayName $AppName
if ($app)
{
$cer = $certPrimary.Certificate
$certValue = [System.Convert]::ToBase64String($cer.GetRawCertData())

az ad app credential reset --append --id $app.ApplicationId --cert $certValue
}
}

# Set secret to AAD app
function Generate-AADApplication([string]$appName, [string]$websiteName) {
$app = Get-AzureRmADApplication -DisplayName $appName
Expand All @@ -289,11 +304,14 @@ function Generate-AADApplication([string]$appName, [string]$websiteName) {
}
else {
$app = New-AzureRmADApplication -DisplayName $appName -IdentifierUris "https://$tenantName/$appName"

$cer = $certPrimary.Certificate
$certValue = [System.Convert]::ToBase64String($cer.GetRawCertData())

New-AzureRmADAppCredential -ApplicationId $app.ApplicationId -CertValue $certValue -StartDate $cer.NotBefore -EndDate $cer.NotAfter
}
}

if ($app)
{
$urls = $app.IdentifierUris
if ($urls.Count -eq 0) {
Set-AzureRmADApplication -ObjectId $app.ObjectId -IdentifierUris "https://$tenantName/$appName" -ErrorAction SilentlyContinue
}
}

Expand Down Expand Up @@ -530,7 +548,7 @@ function Setup-Secrets {
Setup-Secret -VaultName $vaultName -SecretName $secretName -Value $tValue

$secretName = $prefix + "serviceResourceId"
Setup-Secret -VaultName $vaultName -SecretName $secretName -Value "https://$tenantName/$serviceAppName"
Setup-Secret -VaultName $vaultName -SecretName $secretName -Value $azureADApplicationConfiggenResourceId

$secretName = $prefix + "mongoDbUrl"
Setup-Secret -VaultName $vaultName -SecretName $secretName -Value "test"
Expand Down Expand Up @@ -718,7 +736,9 @@ Push-Location $PSScriptRoot

Write-Host -ForegroundColor Green "Total estimated time to complete: 2 to 4 hours"

Install-Modules
if ($installModules -eq 'y') {
Install-Modules
}

Check-FilePath

Expand Down Expand Up @@ -807,9 +827,13 @@ $azureADApplicationConfiggen = Generate-AADApplication -appName $serviceAppName
$azureADApplicationApplicationId = $azureADApplication.ApplicationId.Guid
$azureADApplicationConfiggenApplicationId = $azureADApplicationConfiggen.ApplicationId.Guid

$azureADApplicationConfiggenResourceId = $azureADApplicationConfiggen.IdentifierUris[0]

$azureADAppSecret = Set-AzureAADAppSecret -AppName $clientAppName
$azureADAppSecretConfiggen = Set-AzureAADAppSecret -AppName $serviceAppName

Set-AzureAADAppCert -AppName $serviceAppName

$azureADAppSecretValue = $azureADAppSecret.Value
$azureADAppSecretConfiggenValue = $azureADAppSecretConfiggen.Value

Expand Down
4 changes: 4 additions & 0 deletions DeploymentCloud/Deployment.DataX/common.parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ deploySample=y

# For deployResources script, you can also specify what you want to run by marking y to the each item below:
# resourceCreation, sparkCreation, serviceFabricCreation, setupSecrets, setupCosmosDB, setupKVAccess

# y if you want to check and install the required powershell modules, n otherwise
installModules=y

# y if you want to deploy all resouces except Spark and Service Fabric, n otherwise
resourceCreation=y

Expand Down

0 comments on commit e035190

Please sign in to comment.