zoukankan      html  css  js  c++  java
  • 【Azure DevOps系列】使ASP.NET Core应用程序托管到Azure Web App Service

    使用Azure DevOps Project设置ASP.NET项目

    file

    我们需要先在Azure面板中创建一个Azure WebApp服务,此处步骤我将省略,然后点击部署中心如下图所示:

    file

    此处我选择的是Azure Repos,当然大家也可以选择GithubLocal GitFTP

    file
    我们需要提前在Azure DevOps中提前创建好应用程序,我这边已经提前创建好了名称为Blog
    .
    file

    创建完后我们会在Azure DevOps Pipeline中看到默认为我们生成的管道信息,他是一个构建刚才那个应用程序并发布的过程。这个过程还是挺方便的,省去了我们一些的配置直接将这些给我们配置好,当然CD其实也配置好了,最终这个应用程序会发布到我们在在这之前创建的Azure WebApp中。

    file

    file

    通过如下该图我们可以看到已经可以访问通了,虽然
    为错误页面其实也没关系的,是因为我数据库一些信息未进行配置,现在呢我们已经将应用程序部署到Azure WebApp中了。当然CI和CD规则我们也可以将其进行修改的。

    file

    我们来看看管道的默认配置,默认的构建过程如下图所示。

    file

    下面代码片段是azure-pipelines.yml文件的相关配置如下所示

    # ASP.NET Core
    # Build and test ASP.NET Core projects targeting .NET Core.
    # Add steps that run tests, create a NuGet package, deploy, and more:
    # https://docs.microsoft.com/azure/devops/pipelines/languages/dotnet-core
    
    trigger:
    - master
    
    jobs:
    - job: ASPNETCore
      pool:
        vmImage: 'ubuntu-latest'
      steps:
      # - task: UseDotNet@2
      #   inputs:
      #     packageType: 'sdk'
      #     version: '3.1.x'
    
      - task: DotNetCoreCLI@2
        displayName: Build
        inputs:
          command: build
          projects: '**/*.sln'
          arguments: '--configuration Release -p:Version=10.5.$(Build.BuildId)-official'
    
      - task: DotNetCoreCLI@2
        displayName: Test
        inputs:
          command: test
          projects: '**/*Tests/*.csproj'
          arguments: '--configuration Release'
    
      - task: DotNetCoreCLI@2
        inputs:
          command: publish
          publishWebProjects: True
          arguments: '--configuration Release -p:Version=10.5.$(Build.BuildId)-official --output $(Build.ArtifactStagingDirectory)'
          zipAfterPublish: True
    
      - task: PublishBuildArtifacts@1
        inputs:
          pathtoPublish: '$(Build.ArtifactStagingDirectory)' 
          artifactName: 'Drop'
    
    

    当然在上面步骤中的DotNetCoreCLI@2任务会发布并并打包应用程序,我们可以在下图所示页面中进行下载发布后的应用程序。

    file

  • 相关阅读:
    U**ty a*d Cooperat*o* Are the I*ter*at*o*al Commu**ty's Most *ote*t Weapo* to Overcome the *a*dem*c *art1
    Easy win for Barca as Messi pays homage to Maradona and Lenglet suffers ankle injury
    Ch**a's ma**ed submers*ble Fe*douzhe retur*s after ocea* exped*t*o*
    Documentarian Michael Wood: Chinese people key to reform 2020-11-28
    Timeline of Argentine football legend Maradona's life 2020-11-27
    Chang'e 5 sets out to collect moon samples in landmark mission 2020-11-25
    US companies looking at China for growth, says CNBC 2020-11-24
    [SJ-20-JCR2]-COMPLETE COVERAGE
    Latex应用语法记录
    排序算法学习
  • 原文地址:https://www.cnblogs.com/yyfh/p/13651116.html
Copyright © 2011-2022 走看看