Skip to content

Commit c04f1a0

Browse files
committed
feat: Implement deployment script for function app code and remove JSON template
- Added a deployment script to copy function app code from GitHub to Azure Storage using Azure CLI. - Removed the JSON deployment template in favor of Bicep for better maintainability. - Updated function app configuration to depend on the new deployment script. - Created a PowerShell script to facilitate manual deployment of function code to Azure Storage.
1 parent 8584cbc commit c04f1a0

7 files changed

Lines changed: 151 additions & 1563 deletions

File tree

.github/workflows/release-function-app.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ name: Release Function App
33
on:
44
push:
55
branches: [main]
6-
paths:
7-
- 'fn_*/**'
8-
- 'shared/**'
9-
- 'requirements.txt'
10-
- 'host.json'
116
workflow_dispatch:
127

138
permissions:
@@ -60,6 +55,6 @@ jobs:
6055
- name: Verify release
6156
run: |
6257
echo "✅ Release published successfully"
63-
echo "📥 Download URL: https://github.com/${{ github.repository }}/releases/latest/download/function-app.zip"
58+
echo "📥 Download URL: https://github.com/${{ github.repository }}/releases/download/latest/released-package.zip"
6459
env:
6560
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,17 +90,17 @@ az group create --name rg-intune-analytics --location uksouth
9090
# For ADX backend:
9191
az deployment group create \
9292
--resource-group rg-intune-analytics \
93-
--template-file deployment/deploy-adx.json \
94-
--parameters baseName=intune-analytics
93+
--template-file deployment/adx/main.json \
94+
--parameters baseName=intune
9595

9696
# For Log Analytics backend:
9797
az deployment group create \
9898
--resource-group rg-intune-analytics \
99-
--template-file deployment/deploy-loganalytics.json \
100-
--parameters baseName=intune-analytics
99+
--template-file deployment/loganalytics/main.json \
100+
--parameters baseName=intune
101101
```
102102

103-
> **Automatically deployed**: Storage, Function App, database (ADX or Log Analytics), schema, and function code from GitHub
103+
> **Automatically deployed**: Storage, Function App, and function code from GitHub releases
104104
105105
### 2. Grant Graph API Permissions (Required Post-Deployment Step)
106106

deployment/adx/main.bicep

Lines changed: 44 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,46 @@ resource deploymentContainer 'Microsoft.Storage/storageAccounts/blobServices/con
6969
}
7070
}
7171

72+
// ============================================================================
73+
// Deployment Script: Copy function app code from GitHub to storage
74+
// ============================================================================
75+
76+
resource deploymentScript 'Microsoft.Resources/deploymentScripts@2023-08-01' = {
77+
name: '${baseName}-deploy-code'
78+
location: location
79+
kind: 'AzureCLI'
80+
properties: {
81+
azCliVersion: '2.52.0'
82+
timeout: 'PT10M'
83+
retentionInterval: 'PT1H'
84+
cleanupPreference: 'OnSuccess'
85+
environmentVariables: [
86+
{ name: 'STORAGE_ACCOUNT', value: storageAccount.name }
87+
{ name: 'STORAGE_KEY', value: storageAccount.listKeys().keys[0].value }
88+
{ name: 'CONTAINER_NAME', value: 'deploymentpackage' }
89+
{ name: 'ZIP_URL', value: 'https://github.com/JacobWLMS/IntuneReporting/releases/download/latest/released-package.zip' }
90+
]
91+
scriptContent: '''
92+
# Download from GitHub
93+
curl -L -o /tmp/released-package.zip "$ZIP_URL"
94+
95+
# Upload to storage using account key
96+
az storage blob upload \
97+
--account-name "$STORAGE_ACCOUNT" \
98+
--account-key "$STORAGE_KEY" \
99+
--container-name "$CONTAINER_NAME" \
100+
--name "released-package.zip" \
101+
--file /tmp/released-package.zip \
102+
--overwrite
103+
104+
echo "✅ Function code deployed to storage"
105+
'''
106+
}
107+
dependsOn: [
108+
deploymentContainer
109+
]
110+
}
111+
72112
// ============================================================================
73113
// App Service Plan (Flex Consumption)
74114
// ============================================================================
@@ -169,19 +209,9 @@ resource functionApp 'Microsoft.Web/sites@2024-04-01' = {
169209
]
170210
}
171211
}
172-
}
173-
174-
// ============================================================================
175-
// One Deploy: Deploy function code from GitHub release
176-
// ============================================================================
177-
178-
resource oneDeploy 'Microsoft.Web/sites/extensions@2024-04-01' = {
179-
parent: functionApp
180-
name: 'onedeploy'
181-
properties: {
182-
packageUri: 'https://github.com/JacobWLMS/IntuneReporting/releases/download/latest/released-package.zip'
183-
type: 'zip'
184-
}
212+
dependsOn: [
213+
deploymentScript
214+
]
185215
}
186216

187217
// ============================================================================
@@ -194,5 +224,5 @@ output managedIdentityObjectId string = managedIdentity.properties.principalId
194224
output managedIdentityClientId string = managedIdentity.properties.clientId
195225
output storageAccountName string = storageAccount.name
196226

197-
output nextStep string = 'IMPORTANT: Run scripts/Grant-GraphPermissions.ps1 to grant Microsoft Graph API permissions to the Managed Identity. This requires the Application Administrator role in Entra ID.'
227+
output nextStep string = 'IMPORTANT: Run scripts/Grant-GraphPermissions.ps1 to grant Microsoft Graph API permissions to the Managed Identity.'
198228
output grantPermissionsCommand string = '.\\scripts\\Grant-GraphPermissions.ps1 -ManagedIdentityObjectId "${managedIdentity.properties.principalId}"'

deployment/adx/main.json

Lines changed: 0 additions & 229 deletions
This file was deleted.

0 commit comments

Comments
 (0)