Skip to content

Commit

Permalink
Offline deployment (#32)
Browse files Browse the repository at this point in the history
* Added a new document on steps to deploy offline.
* Updated bicep files to not deploy the FunctionApp.zip when running an offline deployment.
  • Loading branch information
WillyMoselhy authored Nov 6, 2024
1 parent df7e718 commit 1c73bc4
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 33 deletions.
10 changes: 9 additions & 1 deletion Build/Build-Zip-File.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,21 @@ $filesToUpdate = @(
BannerPattern = '("uri": "https://github.com/Azure/AVDReplacementPlans/blob/)(.*)(/docs/Permissions.md")'
}
@{
Path = '.\deploy\bicep\modules\deployFunctionApp.bicep'
Path = '.\deploy\bicep\DeployAVDSessionHostReplacer.bicep'
BannerPattern = "(param FunctionAppZipUrl string = 'https://github.com/Azure/AVDSessionHostReplacer/releases/download/)(.*)(/FunctionApp.zip')"
}
@{
Path = '.\docs\CodeDeploy.md'
BannerPattern = "(TemplateUri = 'https://raw.githubusercontent.com/Azure/AVDSessionHostReplacer/)(.+)(/deploy/arm/DeployAVDSessionHostReplacer.json')"
}
@{
Path = '.\docs\CodeDeploy-offline.md'
BannerPattern = "(\* \[DeployAVDSessionHostReplacer.json\]\(https://github.com/Azure/AVDSessionHostReplacer/releases/download/)(.+)(/DeployAVDSessionHostReplacer.json\))"
}
@{
Path = '.\docs\CodeDeploy-offline.md'
BannerPattern = "(\* \[FunctionApp.zip\]\(https://github.com/Azure/AVDSessionHostReplacer/releases/download/)(.+)(/FunctionApp.zip\))"
}
)

foreach($file in $filesToUpdate){
Expand Down
2 changes: 1 addition & 1 deletion FunctionApp/profile.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Set-PSFConfig -FullName PSFramework.Message.style.NoColor -Value $true #This is

## Version Banner ## Updated by Build\Build-Zip-File.ps1

Write-PSFMessage -Level Host -Message "This is SessionHostReplacer version {0}" -StringValues 'v0.3.0'
Write-PSFMessage -Level Host -Message "This is SessionHostReplacer version {0}" -StringValues 'v0.3.1-beta.6'


# Import Function Parameters
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ the AVD Session Host Replacer helps you manage the task of replacing old session

| Deployment Type | Link |
| :------------------------ | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Azure Portal UI | [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#blade/Microsoft_Azure_CreateUIDef/CustomDeploymentBlade/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAVDSessionHostReplacer%2Fv0.3.0%2Fdeploy%2Farm%2FDeployAVDSessionHostReplacer.json/uiFormDefinitionUri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAVDSessionHostReplacer%2Fv0.3.0%2Fdeploy%2Fportal-ui%2Fportal-ui.json) [![Deploy to Azure Gov](https://aka.ms/deploytoazuregovbutton)](https://portal.azure.us/#blade/Microsoft_Azure_CreateUIDef/CustomDeploymentBlade/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAVDSessionHostReplacer%2Fv0.3.0%2Fdeploy%2Farm%2FDeployAVDSessionHostReplacer.json/uiFormDefinitionUri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAVDSessionHostReplacer%2Fv0.3.0%2Fdeploy%2Fportal-ui%2Fportal-ui.json) [![Deploy to Azure China](https://aka.ms/deploytoazurechinabutton)](https://portal.azure.cn/#blade/Microsoft_Azure_CreateUIDef/CustomDeploymentBlade/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAVDSessionHostReplacer%2Fv0.3.0%2Fdeploy%2Farm%2FDeployAVDSessionHostReplacer.json/uiFormDefinitionUri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAVDSessionHostReplacer%2Fv0.3.0%2Fdeploy%2Fportal-ui%2Fportal-ui.json) |
| Azure Portal UI | [![Deploy to Azure](https://aka.ms/deploytoazurebutton)](https://portal.azure.com/#blade/Microsoft_Azure_CreateUIDef/CustomDeploymentBlade/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAVDSessionHostReplacer%2Fv0.3.1-beta.6%2Fdeploy%2Farm%2FDeployAVDSessionHostReplacer.json/uiFormDefinitionUri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAVDSessionHostReplacer%2Fv0.3.1-beta.6%2Fdeploy%2Fportal-ui%2Fportal-ui.json) [![Deploy to Azure Gov](https://aka.ms/deploytoazuregovbutton)](https://portal.azure.us/#blade/Microsoft_Azure_CreateUIDef/CustomDeploymentBlade/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAVDSessionHostReplacer%2Fv0.3.1-beta.6%2Fdeploy%2Farm%2FDeployAVDSessionHostReplacer.json/uiFormDefinitionUri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAVDSessionHostReplacer%2Fv0.3.1-beta.6%2Fdeploy%2Fportal-ui%2Fportal-ui.json) [![Deploy to Azure China](https://aka.ms/deploytoazurechinabutton)](https://portal.azure.cn/#blade/Microsoft_Azure_CreateUIDef/CustomDeploymentBlade/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAVDSessionHostReplacer%2Fv0.3.1-beta.6%2Fdeploy%2Farm%2FDeployAVDSessionHostReplacer.json/uiFormDefinitionUri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2FAVDSessionHostReplacer%2Fv0.3.1-beta.6%2Fdeploy%2Fportal-ui%2Fportal-ui.json) |
| Command line (Bicep/ARM) | [![Powershell/Azure CLI](./docs/icons/powershell.png)](./docs/CodeDeploy.md)
| Offline Deployment | [![Offline Deployment](./docs/icons/powershell.png)](./docs/CodeDeploy-offline.md) |

## Pre-requisites
The Session Host Replacer requires permissions to manage resources in Azure and, if the session hosts are Entra joined, permissions in Entra. The recommended approach is to create a User Managed Identity, assign the necessary permissions to it, and use it for all instances of the Session Host Replacer.
Expand Down
8 changes: 4 additions & 4 deletions StandardSessionHostTemplate/DeploySessionHosts.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "11784787085459809456"
"version": "0.30.23.60470",
"templateHash": "18178878272492658007"
}
},
"parameters": {
Expand Down Expand Up @@ -135,8 +135,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "10911582647457079552"
"version": "0.30.23.60470",
"templateHash": "18423800479986568485"
}
},
"parameters": {
Expand Down
74 changes: 54 additions & 20 deletions deploy/arm/DeployAVDSessionHostReplacer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "7416287688351186923"
"version": "0.30.23.60470",
"templateHash": "5896702691184782161"
}
},
"parameters": {
Expand All @@ -16,6 +16,20 @@
"description": "Required: No | Region of the Function App. This does not need to be the same as the location of the Azure Virtual Desktop Host Pool. | Default: Location of the resource group."
}
},
"OfflineDeploy": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Required: No | Boolean to enable offline deployment of the Function App. | Default: false"
}
},
"FunctionAppZipUrl": {
"type": "string",
"defaultValue": "https://github.com/Azure/AVDSessionHostReplacer/releases/download/v0.3.1-beta.6/FunctionApp.zip",
"metadata": {
"description": "Required: No | URL of the FunctionApp.zip file. This is the zip file containing the Function App code. Must be provided when OfflineDeploy is set to false | Default: The latest release of the Function App code."
}
},
"EnableMonitoring": {
"type": "bool",
"defaultValue": true
Expand Down Expand Up @@ -399,6 +413,12 @@
"Location": {
"value": "[parameters('Location')]"
},
"OfflineDeploy": {
"value": "[parameters('OfflineDeploy')]"
},
"FunctionAppZipUrl": {
"value": "[parameters('FunctionAppZipUrl')]"
},
"FunctionAppName": {
"value": "[variables('varFunctionAppName')]"
},
Expand Down Expand Up @@ -541,8 +561,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "17223373059197527263"
"version": "0.30.23.60470",
"templateHash": "10735572881969364545"
}
},
"parameters": {
Expand Down Expand Up @@ -574,11 +594,18 @@
"description": "Required: Yes | Name of the Function App."
}
},
"OfflineDeploy": {
"type": "bool",
"defaultValue": false,
"metadata": {
"description": "Required: No | Boolean to enable offline deployment of the Function App. | Default: false"
}
},
"FunctionAppZipUrl": {
"type": "string",
"defaultValue": "https://github.com/Azure/AVDSessionHostReplacer/releases/download/v0.3.0/FunctionApp.zip",
"defaultValue": "",
"metadata": {
"description": "Required: No | URL of the FunctionApp.zip file. This is the zip file containing the Function App code. | Default: The latest release of the Function App code."
"description": "Required: No | URL of the FunctionApp.zip file. This is the zip file containing the Function App code. Must be provided when OfflineDeploy is set to false | Default: Empty"
}
},
"AppPlanName": {
Expand Down Expand Up @@ -615,8 +642,9 @@
},
"resources": [
{
"condition": "[not(parameters('OfflineDeploy'))]",
"type": "Microsoft.Web/sites/extensions",
"apiVersion": "2023-01-01",
"apiVersion": "2023-12-01",
"name": "[format('{0}/{1}', parameters('FunctionAppName'), 'MSDeploy')]",
"properties": {
"packageUri": "[parameters('FunctionAppZipUrl')]"
Expand Down Expand Up @@ -746,8 +774,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "17584014780822218958"
"version": "0.30.23.60470",
"templateHash": "1855754008854946998"
}
},
"parameters": {
Expand Down Expand Up @@ -822,8 +850,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "8573904393442968176"
"version": "0.30.23.60470",
"templateHash": "11915211720288470111"
}
},
"parameters": {
Expand All @@ -842,8 +870,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "11784787085459809456"
"version": "0.30.23.60470",
"templateHash": "18178878272492658007"
}
},
"parameters": {
Expand Down Expand Up @@ -973,8 +1001,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "10911582647457079552"
"version": "0.30.23.60470",
"templateHash": "18423800479986568485"
}
},
"parameters": {
Expand Down Expand Up @@ -1300,8 +1328,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "852792330190262115"
"version": "0.30.23.60470",
"templateHash": "2574188172202499390"
}
},
"parameters": {
Expand Down Expand Up @@ -1361,8 +1389,8 @@
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.29.47.4906",
"templateHash": "852792330190262115"
"version": "0.30.23.60470",
"templateHash": "2574188172202499390"
}
},
"parameters": {
Expand Down Expand Up @@ -1394,5 +1422,11 @@
"[resourceId('Microsoft.Resources/deployments', 'deployStandardSessionHostTemplate')]"
]
}
]
],
"outputs": {
"functionAppName": {
"type": "string",
"value": "[variables('varFunctionAppName')]"
}
}
}
12 changes: 12 additions & 0 deletions deploy/bicep/DeployAVDSessionHostReplacer.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@
@description('Required: No | Region of the Function App. This does not need to be the same as the location of the Azure Virtual Desktop Host Pool. | Default: Location of the resource group.')
param Location string = resourceGroup().location

// FunctionApp
@description('Required: No | Boolean to enable offline deployment of the Function App. | Default: false')
param OfflineDeploy bool = false

@description('Required: No | URL of the FunctionApp.zip file. This is the zip file containing the Function App code. Must be provided when OfflineDeploy is set to false | Default: The latest release of the Function App code.')
param FunctionAppZipUrl string = 'https://github.com/Azure/AVDSessionHostReplacer/releases/download/v0.3.1-beta.6/FunctionApp.zip'

//Monitoring
param EnableMonitoring bool = true
param UseExistingLAW bool = false
Expand Down Expand Up @@ -447,6 +454,8 @@ module deployFunctionApp 'modules/deployFunctionApp.bicep' = {
name: 'deployFunctionApp'
params: {
Location: Location
OfflineDeploy: OfflineDeploy
FunctionAppZipUrl: FunctionAppZipUrl
FunctionAppName: varFunctionAppName
EnableMonitoring: EnableMonitoring
UseExistingLAW: UseExistingLAW
Expand Down Expand Up @@ -491,3 +500,6 @@ module RBACTemplateSpec 'modules/RBACRoleAssignment.bicep' = if (!UseUserAssigne
Scope: deployStandardSessionHostTemplate.outputs.TemplateSpecResourceId
}
}

//---- Outputs ----//
output functionAppName string = varFunctionAppName
9 changes: 6 additions & 3 deletions deploy/bicep/modules/deployFunctionApp.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ param LogAnalyticsWorkspaceId string = 'none'
@description('Required: Yes | Name of the Function App.')
param FunctionAppName string

@description('Required: No | URL of the FunctionApp.zip file. This is the zip file containing the Function App code. | Default: The latest release of the Function App code.')
param FunctionAppZipUrl string = 'https://github.com/Azure/AVDSessionHostReplacer/releases/download/v0.3.0/FunctionApp.zip'
@description('Required: No | Boolean to enable offline deployment of the Function App. | Default: false')
param OfflineDeploy bool = false

@description('Required: No | URL of the FunctionApp.zip file. This is the zip file containing the Function App code. Must be provided when OfflineDeploy is set to false | Default: Empty')
param FunctionAppZipUrl string = ''

@description('Required: No | App Service Plan Name | Default: Y1 for consumption based plan')
param AppPlanName string = 'Y1'
Expand Down Expand Up @@ -182,7 +185,7 @@ resource functionApp 'Microsoft.Web/sites@2023-01-01' = {
}
}
}
resource deployFromZip 'extensions@2023-01-01' = {
resource deployFromZip 'extensions@2023-12-01' = if (!OfflineDeploy) {
name: 'MSDeploy'
properties: {
packageUri: FunctionAppZipUrl
Expand Down
4 changes: 2 additions & 2 deletions deploy/portal-ui/portal-ui.json
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@
"options": {
"icon": "Info",
"text": "When using a User Assigned Managed Identity, make sure the identity has the needed permissions in Azure and Entra. Follow the link for more info.",
"uri": "https://github.com/Azure/AVDReplacementPlans/blob/v0.3.0/docs/Permissions.md"
"uri": "https://github.com/Azure/AVDReplacementPlans/blob/v0.3.1-beta.6/docs/Permissions.md"
}
}
]
Expand Down Expand Up @@ -193,7 +193,7 @@
"type": "Microsoft.Common.TextBlock",
"visible": true,
"options": {
"text": "AVD session host replacer Portal UI Version: v0.3.0",
"text": "AVD session host replacer Portal UI Version: v0.3.1-beta.6",
"link": {
"label": "GitHub Repository",
"uri": "https://github.com/Azure/AVDSessionHostReplacer"
Expand Down
Loading

0 comments on commit 1c73bc4

Please sign in to comment.