57 lines
1.8 KiB
YAML
57 lines
1.8 KiB
YAML
trigger:
|
|
- main
|
|
|
|
pool:
|
|
vmImage: 'ubuntu-latest'
|
|
|
|
variables:
|
|
- group: MyVariableGroup
|
|
|
|
stages:
|
|
- stage: DeployInfrastructure
|
|
displayName: 'Deploy Infrastructure'
|
|
jobs:
|
|
- job: Deploy
|
|
displayName: 'Deploy Resources'
|
|
steps:
|
|
- task: AzureCLI@2
|
|
inputs:
|
|
azureSubscription: $(azureServiceConnection)
|
|
scriptType: 'bash'
|
|
scriptLocation: 'inlineScript'
|
|
inlineScript: |
|
|
# Create resource group
|
|
az group create --name $(resourceGroupName) --location $(location)
|
|
|
|
# Create storage account
|
|
az storage account create --name $(storageAccountName) --location $(location) --resource-group $(resourceGroupName) --sku Standard_LRS
|
|
|
|
# Create Function App with Consumption Plan
|
|
az functionapp create --consumption-plan-location $(location) --name $(functionAppName) --os-type Linux --resource-group $(resourceGroupName) --runtime python --runtime-version 3.11 --storage-account $(storageAccountName)
|
|
|
|
- stage: DeployCode
|
|
displayName: 'Deploy Code'
|
|
dependsOn: DeployInfrastructure
|
|
jobs:
|
|
- job: Deploy
|
|
displayName: 'Deploy Function App Code'
|
|
steps:
|
|
- checkout: self
|
|
- script: |
|
|
python3.11 -m venv .venv
|
|
source .venv/bin/activate
|
|
pip install -r requirements.txt
|
|
displayName: 'Install dependencies'
|
|
- task: ArchiveFiles@2
|
|
inputs:
|
|
rootFolderOrFile: '$(System.DefaultWorkingDirectory)'
|
|
includeRootFolder: false
|
|
archiveType: 'zip'
|
|
archiveFile: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip'
|
|
replaceExistingArchive: true
|
|
- task: AzureWebApp@1
|
|
inputs:
|
|
azureSubscription: $(azureServiceConnection)
|
|
appType: 'functionapp'
|
|
appName: $(functionAppName)
|
|
package: '$(Build.ArtifactStagingDirectory)/$(Build.BuildId).zip' |