Search code examples
dockeroauth-2.0backgroundworkerazure-appservice

Failed to retrieve OIDC token from "https://login.microsoftonline.com/*/oauth2/v2.0/token"


I am using OAuth for Kafka Message Consumption using C#. It's on .Net Core Background Service Worker class. I Registered app on Azure and using it for OAuth authentication

GroupId = secret.ConsumerGroup,
BootstrapServers = secret.BootstrapServer,
SecurityProtocol = SecurityProtocol.SaslSsl,
SaslMechanism = SaslMechanism.OAuthBearer,
SaslOauthbearerMethod = SaslOauthbearerMethod.Oidc,
SaslOauthbearerClientId = secret.SaslOauthbearerClientId,
SaslOauthbearerClientSecret = secret.SaslOauthbearerClientSecret,
SaslOauthbearerScope = secret.SaslOauthbearerScope,
SaslOauthbearerTokenEndpointUrl = secret.SaslOauthbearerTokenEndpointUrl

And here is my Docker file ( Build Artefacts are published on Azure Pipeline )

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/sdk:6.0 AS build
WORKDIR /src

FROM base AS final

WORKDIR /app
COPY . .
ENTRYPOINT ["dotnet", "myapp.dll"]

This Service is working file when I run it locally, But when Containerized and Pushed on Azure App Service (Linux App Service Plan). I'm getting below error:

Failed to retrieve OIDC token from "https://login.microsoftonline.com/e11fd634-26b5-47f4-8b8c-908e466e9bdf/oauth2/v2.0/token": error setting certificate file: /etc/pki/tls/certs/ca-bundle.crt (-1)

Anyone know about this issue? please help me


Solution

  • I've used this reference and tried below solution. It's working well for me

    RUN mkdir -p /etc/pki/tls/certs/
    RUN ln -s /usr/lib/ssl/certs/ca-certificates.crt /etc/pki/tls/certs/ca-bundle.crt