How to include Azure Function secrets when deploying to Kubernetes?

4/28/2019

I have built a .NET Core Azure Function using a ServiceBusTrigger. The function works fine when deployed in a regular App Service plan once the appropriate Application settings, such as the Service Bus connection string.

However, I would prefer to host the function as a Docker container on Azure Kubernetes Service (AKS). I have AKS setup and have a number of .NET Core Docker containers running fine there, including some Azure Functions on TimerTriggers.

When I deploy the function using the ServiceBusTrigger, it fails to properly tun and I get "Function host is not running." when I visit the functions IP address. I believe this is because the app settings are not being found.

The problem is I do not know how to include them when hosting in the Docker/Kubernetes environment. I've tried including the appropriate ENV entries in the Docker file, but then I cannot find the corresponding values in the deployment YAML viewed via the Kubernetes dashboard after I've successfully run func deploy from PowerShell.

Most of the Microsoft documentation addresses the TimerTrigger and HttpTrigger cases, but I can find little on the ServiceBusTrigger when using Docker/Kubernetes.

So, how do I include with the appropriate app settings with my deployment?

-- ProfNimrod
.net-core
azure-aks
azure-functions
docker
kubernetes

1 Answer

4/29/2019

From this Blog :Playing with Azure Functions kubernetes integration, you could find a description about add environment variables.

In the deployment.yml, add the env(like AzureWebJobsStorage as an environment variable).

containers:
    - image: tsuyoshiushio/queuefunction-azurefunc
      imagePullPolicy: Always
      name: queuefunction-deployment
      env:
        - name: AzureWebJobsStorage
          value: YOUR_STORAGE_ACCOUNT_CONNECTION_STRING_HERE
      ports:
        - containerPort: 80
      protocol: TCP

Then apply it, it will works.

-- George Chen
Source: StackOverflow