【问题标题】:Azure Function deployed via Azure DevOps pipeline not executing通过 Azure DevOps 管道部署的 Azure 函数未执行
【发布时间】:2020-12-15 19:52:34
【问题描述】:

我创建了一个 azure 管道,用于部署具有 azure 功能的自定义 docker 映像,并具有以下配置。虽然配置在构建方面有效,但没有任何功能在服务器上运行,我注意到在日志中没有检测到任何功能。

pool:
  name: Azure Pipelines
steps:
- task: Docker@1
  displayName: 'build: build the docker image'
  inputs:
    azureSubscriptionEndpoint: 'Azure subscription 1 (3fc75102-5159-4491-b61c-b3fcb845f648)'
    azureContainerRegistry: whaiiapp.azurecr.io
    imageName: 'azureapp.azurecr.io/puppeteer:$(Build.BuildId)'
    useDefaultContext: false

- task: Docker@1
  displayName: 'push the image'
  inputs:
    azureSubscriptionEndpoint: 'Azure subscription 1 (3fc75102-5159-4491-b61c-b3fcb845f648)'
    azureContainerRegistry: azureapp.azurecr.io
    command: 'Push an image'
    imageName: 'azureap.azurecr.io/puppeteer:$(Build.BuildId)'

- task: FuncToolsInstaller@0
  displayName: 'Install func tools - latest'

- task: AzureFunctionAppContainer@1
  displayName: 'Start Azure Function App on Container Deploy: generate-report-dev'
  inputs:
    azureSubscription: 'Azure subscription 1 (3fc75102-5159-4491-b61c-b3fcb845f648)'
    appName: 'generate-report-dev'
    imageName: azureapp.azurecr.io/puppeteer
    containerCommand: 'npm start'

以下是我的 Dockerfile 配置

FROM mcr.microsoft.com/azure-functions/node:3.0-appservice

# Chromium dependencies
RUN apt-get update -yq \
&& apt-get install -yq git git-extras gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 \
libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 \
libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 \
libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 \
fonts-ipafont-gothic fonts-wqy-zenhei fonts-thai-tlwg fonts-kacst libgbm-dev \
ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget && \
wget https://github.com/Yelp/dumb-init/releases/download/v1.2.2/dumb-init_1.2.2_amd64.deb && \
dpkg -i dumb-init_*.deb && rm -f dumb-init_*.deb && \
apt-get clean && apt-get autoremove -y && rm -rf /var/lib/apt/lists/*

WORKDIR /home/site/wwwroot

RUN npm install --no-save puppeteer

ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true \
    FUNCTIONS_WORKER_RUNTIME=node \

COPY . /home/site/wwwroot

RUN cd /home/site/wwwroot && npm install

CMD [ "npm start" ]

我不确定如何进行调试。我尝试通过 ssh 登录服务器并运行 func start 来测试它,它显示 func 命令不可用。

【问题讨论】:

  • 那么你的构建成功了吗?我看到你的yaml文件的配置也是正确的。尝试在本地构建和部署时是否存在同样的问题?
  • 嗨,部署上线,但未检测到功能。我在本地运行了相同的 docker 映像,它可以工作

标签: azure docker azure-devops azure-function-app


【解决方案1】:

我相信您的 azure 函数无法从注册表中提取图像,我确实遇到了同样的问题,所以我只是创建了新的函数应用程序,然后在部署过程中选择了存储库,所以它将在后面创建一个 webhook每次更新时都会从注册表中提取最新图像的场景。

【讨论】:

    猜你喜欢
    • 2021-07-23
    • 2020-08-27
    • 2020-10-22
    • 2019-08-12
    • 1970-01-01
    • 2022-12-05
    • 2019-12-03
    • 1970-01-01
    • 2019-10-20
    相关资源
    最近更新 更多