An Azure service that provides an event-driven serverless compute platform.
Hello Smooth Dev,
To deploy an Azure Function App using an Azure DevOps pipeline, follow these steps:
Step 1: Set Up the Azure DevOps Pipeline
- Create a new YAML pipeline linked to your Azure Repos repository containing the function app code.
Add the following YAML configuration to automate the build and deployment process. Here's an example for a Node.js Azure Function App:
trigger:
branches:
include:
- main # Triggers the pipeline when changes are pushed to the main branch
pool:
vmImage: 'ubuntu-latest' # Select VM image based on your environment
steps:
- task: UseNode@2 # For Node.js apps. Replace with Python or .NET task if needed
inputs:
versionSpec: '14.x'
- task: NodeTool@0 # Installs Node.js. Modify as needed for other runtimes.
inputs:
versionSpec: '14.x'
- task: Npm@1 # Installs dependencies for Node.js apps
inputs:
command: 'install'
- task: AzureFunctionApp@1 # Deploys the Azure Function App
inputs:
azureSubscription: 'Your-Service-Connection-Name' # Replace with your service connection
appType: 'functionAppLinux' # Use 'functionAppWindows' if your app is Windows-based
appName: 'Your-Function-App-Name' # Your Azure Function App name
package: '$(System.DefaultWorkingDirectory)/**/dist' # Adjust this to match your app's output directory
Step 2: Service Connection Setup
You need a Service Connection for Azure DevOps to authenticate and deploy to Azure:
Go to Project Settings > Service Connections.
Click New Service Connection and choose Azure Resource Manager.
Select the appropriate authentication method (Service Principal or Managed Identity).
- Once created, reference this service connection in the azureSubscription field of the YAML.
Step 3: Commit and Push
After setting up your pipeline, commit the YAML file to your repository and push it to the main branch. The pipeline will automatically trigger on every push to main, build the app, and deploy it to your Azure Function App.
Documentation:
- Azure DevOps Pipelines Documentation
- Continuous delivery with Azure Pipelines
- Service Connections in Azure DevOps
- Continuous deployment for Azure Functions
I hope this helps you get your CI/CD pipeline up and running. Let me know if you run into any issues or have further questions along the way. Thank you!