Container didn't respond to HTTP Ping on PORT: 8080, failing site start

Copper Contributor

Problem:

I'm encountering an error during deployment of a containerized Azure Function App using Azure Pipelines. The local Docker desktop environment functions flawlessly, but deployment to Azure results in the following error message:

2024-03-13T06:23:00.486Z ERROR - Container test_0_9048c154 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging

[Application Error] (https://i.stack.imgur.com/phK0d.png)

Environment:

Containerized Azure Function App (dotnet-isolated, C#)
OS: Linux
CI/CD: Azure Pipelines
IDE: Visual Studio

Deployment Details:
Image Name: test
Tag: latest

Pipeline Task Logs: 
Successful deployment of container image and app settings update.

Got service connection details for Azure App Service:'test'
Trying to update App Service Configuration settings. Data: {"appCommandLine":null,"linuxFxVersion":"DOCKER|***/test"} 
Updated App Service Configuration settings.
Restarting App Service : test App Service 'test' restarted successfully.
Updating App Service Application settings. Data: {"WEBSITES_ENABLE_APP_SERVICE_STORAGE":"false"} 
App Service Application settings are already present.
Successfully updated deployment History at (redacted) App Service Application URL: (redacted) Finishing: Az Function App Container

Docker.log: 
Container initialization failure (exiting).
Successful middleware container initialization.
HTTP ping failure on container port 8080.

2024-03-13T06:22:53.224Z INFO - Initiating warmup request to container test_0_9048c154 for site test 2024-03-13T06:22:53.416Z ERROR - Container test_0_9048c154 for site test has exited, failing site start 2024-03-13T06:22:53.416Z INFO - Initiating warmup request to container test_0_9048c154_middleware for site test 2024-03-13T06:23:00.185Z INFO - Container test_0_9048c154_middleware for site test initialized successfully and is ready to serve requests. 2024-03-13T06:23:00.486Z ERROR - Container test_0_9048c154 didn't respond to HTTP pings on port: 8080, failing site start. See container logs for debugging

Dockerfile: 
Base image: mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0
Builds and publishes the function app.
Exposes port 8080.
Sets entry point as dotnet Test.dll.

FROM mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated8.0 AS base
WORKDIR /home/site/wwwroot

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Test.csproj", "."]
RUN dotnet restore "./././Test.csproj"
COPY . .
WORKDIR "/src/."
RUN dotnet build "./Test.csproj" -c $BUILD_CONFIGURATION -o /app/build

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./Test.csproj" -c $BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

FROM base AS final
WORKDIR /home/site/wwwroot
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
EXPOSE 8080
ENTRYPOINT ["dotnet", "Test.dll"]

Pipeline YAML: 
Builds and pushes container image to Azure Container Registry (ACR).
Deploys image to Azure Function App using AzureFunctionAppContainer@1 task.

trigger:
- master

resources:
- repo: self

variables:
  # Container registry service connection established during pipeline creation
  dockerRegistryServiceConnection: <redacted>
  imageRepository: 'test'
  containerRegistry: '<redacted>.azurecr.io'
  dockerfilePath: '$(Build.SourcesDirectory)/Dockerfile'
  tag: '$(Build.BuildId)'

  # Agent VM image name
  vmImageName: 'ubuntu-latest'

stages:
- stage: Build
  displayName: Build and push stage
  jobs:
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
    steps:
    - task: Docker@2
      displayName: Build and push an image to container registry
      inputs:
        command: buildAndPush
        repository: $(imageRepository)
        dockerfile: $(dockerfilePath)
        containerRegistry: $(dockerRegistryServiceConnection)
        tags: |
          $(tag)
    - task: AzureFunctionAppContainer@1
      displayName: Az Function App Container  
      inputs:
        azureSubscription: <redacted>
        appType: 'functionAppLinux'
        appName: 'test'
        imageName: '<redacted>.azurecr.io/test:$(tag)'

Azure Function Environment Variable App Setting 
WEBSITES_PORT = 8080
PORT = 8080

The port exposed in dockerfile is matching the app settings (WEBSITES_PORT)

Referring this:

https://azureossd.github.io/2023/02/15/Whats-the-difference-between-PORT-and-WEBSITES_PORT/index.htm...

https://techcommunity.microsoft.com/t5/apps-on-azure-blog/things-you-should-know-web-apps-and-linux/...


Questions:

  1. Am I missing anything?
  2. Does Containerized Azure Function App require any additional setup / configuration / settings?
  3. What are the best practices for deployment using Azure Pipelines?
  4. is container log different from the docker log?
3 Replies

@Rishit Shah 

 

Did you check necessary controls such as NSG, network policy?

@Kidd_Ip We are using managed service (ACR). Hence Network is open.

Thank you for replying @Kidd_Ip 

Below is the Network Setting

Screenshot inbound.png