Call Azure function inside the Kubernetes cluster shows error?

8/10/2020

I Created python azure function and its working fine in the local environment and I attached a storage account. I changed authLevel as below "authLevel": "anonymous".then I created a docker image and deployed in kubernetes cluster using deployment YAML in the azurefunction namespace

apiVersion: apps/v1
kind: Deployment
metadata:
  name: configuration
  labels:
    app: configuration
spec:
  replicas: 2
  selector:
    matchLabels:
      app: configuration
  template:
    metadata:
      labels:
        app: configuration
    spec:
      containers:
      - name: configuration
        image: global.azurecr.io/config:1
        env:
        - name: AzureFunctionsJobHost__functions__0
          value: configuration
        envFrom:
        - secretRef:
            name: configuration
      imagePullSecrets:
      - name: pull

Kubectl create -f configuration.yaml -n azurefunction. also, I created a service for this azure function

kind: Service
apiVersion: v1
metadata:
  name: configuration-service
spec:
  type: NodePort
  ports:
  - name: http
    port: 80
    protocol: TCP
  selector:
    app:  configuration

Kubectl create -f configuration-service.yaml -n azurefunction .I tried to call the Azure function from other namespace using c# code.

var postresponse = await httpClient.GetAsync("http://configuration-service:80/api/ConfigurationInfo");

deployed in api namespace its showing an error

StatusCode: 404, ReasonPhrase: 'Not Found', Version: 1.1, Content: System.Net.Http.HttpConnectionResponseContent, Headers:
-- Arun Thomas
azure
azure-function-app
azure-functions
c#
kubernetes

0 Answers