Create azure_pipeline.yaml
This commit is contained in:
71
azure_pipeline.yaml
Normal file
71
azure_pipeline.yaml
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
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 App Service Plan
|
||||||
|
az appservice plan create --name $(appServicePlanName) --resource-group $(resourceGroupName) --location $(location) --sku Y1 --is-linux
|
||||||
|
|
||||||
|
# Create Function App
|
||||||
|
az functionapp create --name $(functionAppName) --storage-account $(storageAccountName) --resource-group $(resourceGroupName) --plan $(appServicePlanName) --runtime python --runtime-version 3.9 --functions-version 3
|
||||||
|
|
||||||
|
# Create Application Insights
|
||||||
|
az monitor app-insights component create --app $(appInsightsName) --location $(location) --resource-group $(resourceGroupName)
|
||||||
|
|
||||||
|
# Configure Application Insights for Function App
|
||||||
|
appInsightsKey=$(az monitor app-insights component show --app $(appInsightsName) --resource-group $(resourceGroupName) --query "instrumentationKey" --output tsv)
|
||||||
|
az functionapp config appsettings set --name $(functionAppName) --resource-group $(resourceGroupName) --settings "APPINSIGHTS_INSTRUMENTATIONKEY=$appInsightsKey"
|
||||||
|
|
||||||
|
- stage: DeployCode
|
||||||
|
displayName: 'Deploy Code'
|
||||||
|
dependsOn: DeployInfrastructure
|
||||||
|
jobs:
|
||||||
|
- job: Deploy
|
||||||
|
displayName: 'Deploy Function App Code'
|
||||||
|
steps:
|
||||||
|
- checkout: self
|
||||||
|
- task: UsePythonVersion@0
|
||||||
|
inputs:
|
||||||
|
versionSpec: '3.x'
|
||||||
|
addToPath: true
|
||||||
|
- script: |
|
||||||
|
python -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'
|
||||||
Reference in New Issue
Block a user