简体   繁体   中英

Azure Function Runtime Unreachable when deploying from Azure devops pipeline

Thanks for taking the time to read. My current setup is as follows:

I have an azure function service up and running, an az function project in visual studio (which I have tested and it runs without issue), a build pipeline in azure devops that deploys a docker image with my function project to an azure container registry.

My problem:

When I try to setup my function service for CI/CD from my devops pipeline, I get the following error on the "functions" tab on my app: "Azure Functions runtime is unreachable". Also none of the functions from my code are listed. In the deployment center however, I get a message "Deployed successfully to production", and it shows my built docker container image name.

Troubleshooting:

In the deployment center of my function app (in the az portal), I set my app to read directly from the azure container registry (using the exact same docker image that my pipeline built earlier), and that worked perfectly - deployment successful and I could see my individual functions name. When I switched back to CI/CD deployment however I got the same problem as earlier.

Trying to see if anyone has had the same problem or could suggest a path forward for getting CI/CD integration working.

I pasted my yaml file below with some names changed for privacy.

trigger:
- master

pool:
  vmImage: 'ubuntu-latest'

variables:
  project: 'myProjectName'
  environment: 'prod'
  dockerfile: '**/Dockerfile'
  azureResource: 'myScraperFunction'
  imageName: myScraperFunction

steps:
- task: Docker@2
  displayName: Build
  inputs:
    command: build
    containerRegistry: $(azureContainerRegistryName)
    repository: '$(Build.Repository.Name)-$(project)'
    tags: '$(Build.BuildNumber)-$(environment)'
    Dockerfile: $(dockerfile)
    buildContext: '$(Build.SourcesDirectory)'
    arguments: --build-arg PAT=$(System.AccessToken)

- task: Docker@2
  displayName: Push
  inputs:
    command: push
    containerRegistry: $(azureContainerRegistryName)
    repository: '$(Build.Repository.Name)-$(project)'
    tags: '$(Build.BuildNumber)-$(environment)'
    Dockerfile: $(dockerfile)       

- task: AzureFunctionAppContainer@1
  displayName: 'Azure Function App on Container Deploy: $(azureResource)'
  inputs:
    azureSubscription: '$(azureSubscription)'
    appName: $(azureResource)
    imageName: '$(azureContainerRegistry)/$(imageName):$(Build.BuildNumber)-$(environment)'

Configuration/typing issue in yml file. Repository name during build step was hard-coded (I didn't use a variable like what was posted above) and did not match repo name in deploy step because of a spelling error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM