Skip to content

Commit

Permalink
Fixed silent deployment with custom workspace
Browse files Browse the repository at this point in the history
  • Loading branch information
Helder Pinto committed Apr 8, 2024
1 parent dd377e8 commit cb6c4e5
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
12 changes: 8 additions & 4 deletions .github/workflows/continuous-deployment-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AOE_SQL_ADMIN: ${{ secrets.AOE_SQL_ADMIN }}
AOE_SQL_PASSWD: ${{ secrets.AOE_SQL_PASSWD }}
AOE_LOCATION: ${{ secrets.AOE_LOCATION }}
AOE_NAMEPREFIX: ${{ secrets.AOE_NAMEPREFIX }}
AOE_WORKSPACENAME: ${{ secrets.AOE_WORKSPACENAME }}
AOE_WORKSPACERG: ${{ secrets.AOE_WORKSPACERG }}
steps:
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref }} branch of the ${{ github.repository }} repository!"
- name: Installing modules
Expand All @@ -35,14 +39,14 @@ jobs:
run: |
echo '{
"SubscriptionId": "'"$AZURE_SUBSCRIPTION_ID"'",
"NamePrefix": "aoedevgithub",
"NamePrefix": "'"$AOE_NAMEPREFIX"'",
"WorkspaceReuse": "y",
"WorkspaceName": "helderpintopfe",
"WorkspaceResourceGroupName": "pfe-governance-rg",
"WorkspaceName": "'"$AOE_WORKSPACENAME"'",
"WorkspaceResourceGroupName": "'"$AOE_WORKSPACERG"'",
"DeployWorkbooks": "y",
"SqlAdmin": "'"$AOE_SQL_ADMIN"'",
"SqlPass": "'"$AOE_SQL_PASSWD"'",
"TargetLocation": "westeurope",
"TargetLocation": "'"$AOE_LOCATION"'",
"DeployBenefitsUsageDependencies": "n"
}' > ./deploymentSettings.json
- name: Testing PowerShell script call
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/continuous-deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
AOE_SQL_ADMIN: ${{ secrets.AOE_SQL_ADMIN }}
AOE_SQL_PASSWD: ${{ secrets.AOE_SQL_PASSWD }}
AOE_LOCATION: ${{ secrets.AOE_LOCATION }}
AOE_NAMEPREFIX: ${{ secrets.AOE_NAMEPREFIX }}
steps:
- run: echo "This job is now running on a ${{ runner.os }} server hosted by GitHub for the ${{ github.ref }} branch of the ${{ github.repository }} repository!"
- name: Installing modules
Expand All @@ -35,12 +37,12 @@ jobs:
run: |
echo '{
"SubscriptionId": "'"$AZURE_SUBSCRIPTION_ID"'",
"NamePrefix": "aoeprdgithub",
"NamePrefix": "'"$AOE_NAMEPREFIX"'",
"WorkspaceReuse": "n",
"DeployWorkbooks": "y",
"SqlAdmin": "'"$AOE_SQL_ADMIN"'",
"SqlPass": "'"$AOE_SQL_PASSWD"'",
"TargetLocation": "westeurope",
"TargetLocation": "'"$AOE_LOCATION"'",
"DeployBenefitsUsageDependencies": "n"
}' > ./deploymentSettings.json
- name: Testing PowerShell script call
Expand Down
11 changes: 8 additions & 3 deletions Deploy-AzureOptimizationEngine.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,13 @@ if (-not($deploymentOptions["ResourceGroupName"]))
$resourceGroupName = $resourceGroupNameTemplate -f $namePrefix
$storageAccountName = $storageAccountNameTemplate -f $namePrefix
$automationAccountName = $automationAccountNameTemplate -f $namePrefix
$sqlServerName = $sqlServerNameTemplate -f $namePrefix
$laWorkspaceName = $laWorkspaceNameTemplate -f $namePrefix
$sqlServerName = $sqlServerNameTemplate -f $namePrefix
if ("Y", "y" -contains $workspaceReuse -and $silentDeploy) {
$laWorkspaceName = $deploymentOptions["WorkspaceName"]
}
else {
$laWorkspaceName = $laWorkspaceNameTemplate -f $namePrefix
}
$sqlDatabaseName = "azureoptimization"
}

Expand All @@ -393,7 +398,7 @@ if (-not($deploymentOptions["ResourceGroupName"]))
else
{
# With a silent deploy, overrule any custom resource naming if a NamePrefix is provided
if($silentDeploy -and (![string]::IsNullOrEmpty($namePrefix)))
if($silentDeploy -and ![string]::IsNullOrEmpty($namePrefix) -and $namePrefix -ne "EmptyNamePrefix")
{
$deploymentName = $deploymentNameTemplate -f $namePrefix
$resourceGroupName = $resourceGroupNameTemplate -f $namePrefix
Expand Down

0 comments on commit cb6c4e5

Please sign in to comment.