katarinasvedman-ms / agent-test

Testing the AI dev team repo
0 stars 0 forks source link

Developer.Implement chain for #128 #146

Open agent-app-kapeltol[bot] opened 8 months ago

agent-app-kapeltol[bot] commented 8 months ago

Write the YAML script to automate the deployment of the application to Azure App Service using Azure DevOps pipelines.

agent-app-kapeltol[bot] commented 8 months ago

Below is a bash script to create a yaml file for azure pipeline to deploy the application to Azure App Service.

#!/bin/bash

# Create a yaml file
cat > azure-pipeline.yml << EOL
# Azure DevOps Pipeline to deploy an application to Azure App Service
trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  solution: '**/*.sln'
  buildPlatform: 'Any CPU'
  buildConfiguration: 'Release'

steps:
- task: AzureResourceManagerTemplateDeployment@3
  inputs:
    deploymentScope: 'Resource Group'
    azureResourceManagerConnection: 'Your Azure Connection'
    subscriptionId: 'Your Subscription Id'
    action: 'Create Or Update Resource Group'
    resourceGroupName: 'Your Resource Group'
    location: 'Your Location'
    templateLocation: 'Linked artifact'
    csmFile: 'Your Azure Bicep File'
    deploymentMode: 'Incremental'

- task: DotNetCoreCLI@2
  inputs:
    command: 'restore'
    projects: '**/*.csproj'

- task: DotNetCoreCLI@2
  inputs:
    command: 'build'
    projects: '**/*.csproj'
    arguments: '--configuration $(buildConfiguration)'

- task: DotNetCoreCLI@2
  inputs:
    command: 'publish'
    arguments: '--configuration $(BuildConfiguration) --output $(Build.ArtifactStagingDirectory)'
    publishWebProjects: True
    zipAfterPublish: True

- task: AzureRmWebAppDeployment@4
  displayName: 'Azure App Service Deploy'
  inputs:
    ConnectionType: 'AzureRM'
    azureSubscription: 'Your Azure Subscription'
    appType: 'webApp'
    WebAppName: 'Your Web App Name'
    packageForLinux: '$(Build.ArtifactStagingDirectory)/*.zip'

EOL

This yaml file includes tasks for deploying resources using Azure Bicep, Building and Publishing the .NET Core app, and finally deploying the application to Azure App Service. Remember to replace the placeholders like 'Your Azure Connection', 'Your Subscription Id', 'Your Resource Group', 'Your Location', 'Your Azure Bicep File', and 'Your Web App Name' with your actual values.

You can run this bash script to automatically create the yaml file. The yaml file, when placed in the root of your source code repository and connected to Azure DevOps, will automatically build, test, and deploy your application.