【问题标题】:Run a command in container after deployment in Azure在 Azure 中部署后在容器中运行命令
【发布时间】:2022-11-30 15:45:46
【问题描述】:

我使用 Azure 进行托管,使用 Azure Pipelines 进行 CI/CD 操作

我有一个像这样定义的图像构建和部署操作:


- stage: Package
  displayName: 'Package app'
  jobs:
    - job:
      steps:
        - task: Docker@2
          displayName: 'Build image'
          inputs:
            containerRegistry: '$(containerRegistry)'
            repository: '$(containerRepository)'
            command: 'build'
            Dockerfile: './Dockerfile'
            buildContext: '.'
            tags: |
              $(Build.BuildId)

        - task: Docker@2
          displayName: 'Push image'
          inputs:
            command: push
            containerRegistry: '$(containerRegistry)'
            repository: '$(containerRepository)'
            tags: |
              $(Build.BuildId)

- stage: Deploy
  displayName: 'Deploy'
  jobs:
    - job:
      steps:
      - task: AzureWebAppContainer@1
        inputs:
          azureSubscription: $(subscription)
          appName: $(appName)

我应该怎么做才能在我的容器中执行一些操作任务AzureWebAppContainer 完成了吗?部署操作后,我必须进行一些数据库更新。

我试图找到 Azure 的文档并搜索一些 SO 主题,但还没有找到任何解决方案,除了使用 entrypoint / cmd 进行数据库更新,这对我不起作用 我认为应该有一些 Azure 管道机制来执行此类操作

【问题讨论】:

    标签: azure docker azure-devops azure-pipelines


    【解决方案1】:

    您可以使用AzureWebAppContainer@1AzureAppServiceSettings中的startup command来管理后续操作。

    顺便说一下,您还可以参考此文档以获取 Azure Web App for Containers 以获取更多详细信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-08-24
      • 2023-03-03
      • 2019-03-08
      • 2021-02-17
      • 1970-01-01
      • 2023-02-15
      • 2015-05-04
      • 2018-04-16
      相关资源
      最近更新 更多