How to deploy Docker Hub Linux image to Azure Function? Portal for Function already shows my Docker Image!

Siegfried Heintze 1,906 Reputation points
2023-04-29T00:40:44.64+00:00

I have used visual studio to deploy my compiled C# azure function to dockerhub. I did not see any errors in the visual studio output. I logged into docker hub to confirm that it has been pushed: Yes there is a new image there. Then I use a bash prompt:

az functionapp create  --name $FUNC --resource-group  $rg   --storage-account $funcstg --os-type Linux  --image $DOCKERHUB_USERNAME/$DOCKER_IMAGE:v1  --registry-username $DOCKERHUB_USERNAME --registry-password $DOCKERHUB_PASSWORD --resource-group $rg --runtime dotnet --functions-version 4 --consumption-plan-location $loc

I got this in response:

WARNING: Your Linux function app 'funcCrewTaskMgrAuthenticatedServices', that uses a consumption plan has been successfully created but is not active until content is published using Azure Portal or the Functions Core Tools.

WARNING: Application Insights "funcCrewTaskMgrAuthenticatedServices" was created for this Function App. You can visit https://portal.azure.com/#resource/subscriptions/accxxxxxxxxxxxxxxxxxxxxxxxxxdb/resourceGroups/rg_xxxxxxxxx/providers/microsoft.insights/components/funcCrewTaskMgrAuthenticatedServices/overview to view your Application Insights component

I go to my dockerhub account and confirm that the new docker image has been pulled.

I go to the portal.azure.com and go to my azure function app and click on "deployments" and there I see my dockerhub username & password and image name. Looks good!

But then I click on Functions and I see no functions!

  1. Why don't I see any functions?
  2. How do I use the portal to populate my functions?
  3. How do I use azure core tools for this final step? I looked at the documentation and I could not figure out the this final step. The azure core tools tutorial just recommends az functionapp create...like I had already done.
  4. How do I use the azure cli to populate my functions?

Thanks

Siegfried

I found this https://learn.microsoft.com/en-us/answers/questions/1192379/how-to-create-a-functionapp-from-docker-image-in-a it looks like I have already done that that answer recommends.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,909 questions
0 comments No comments
{count} votes

Accepted answer
  1. Ryan Hill 30,281 Reputation points Microsoft Employee Moderator
    2023-04-30T20:42:18.1766667+00:00

    Hey @Siegfried Heintze ,

    You created your function app using the wrong command. Docker images for Function apps aren't supported on Consumption plans. You need create a function app on a premium or dedicated app service plan, az functionapp plan create --resource-group AzureFunctionsContainers-rg --name myPremiumPlan --location <REGION> --number-of-workers 1 --sku EP1 --is-linux.

    See Create a function on Linux using a custom container for more details.


    EDIT 30 May 2023

    From a CLI standpoint, you're not missing anything. I verified this on EP1 as well as B1 Linux plans (az appservice plan create --name plan --sku B1 --is-linux). I basically did the following:

    az functionapp plan create --name plan-ryhill-linux-westus2 --sku EP1 --is-linux true
    az functionapp create --functions-version 4 --name ryhilldockerapponpremium  --os-type linux --runtime dotnet-isolated --storage-account stryhillacct --image xxxregistry.azurecr.io/api:20230530005907 --https-only true --plan plan-ryhill-linux-westus2
    

    to deploy this Dockerfile. The function doesn't show up automatically until the docker image is completely loaded and ready to take requests.

    enter image description here

    Since you're not seeing your function, I would look your deployment logs for any errors and that your container is serving requests.

    enter image description here


1 additional answer

Sort by: Most helpful
  1. Siegfried Heintze 1,906 Reputation points
    2023-06-02T19:58:43.7933333+00:00

    Thank you again Ryan!

    I wish they would give me more helpful error messages!

    Problems solved:

    1. For some strange reason, it is necessary for me to log into my own dockerhub repo to fetch a public image.
    2. I had the tag wrong.

    I'm very glad to learn that I don't need a premium azure function for linux! I must have misunderstood the azure pricing calculator. I had to learn the hard way that even if you delete the function app for a premium function, you are still charged until you delete the premium plan! (Fortunately, I begged for mercy and they are going to refund my those charges).

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.