简体   繁体   中英

How to install Function App Bindings on your own Docker Image

I'm trying to setup an Azure Function App with my own Docker image (as per https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image?tabs=nodejs )

But I can't figure out how to install an Extension (eg CosmosDBTrigger, as per https://docs.microsoft.com/fr-fr/azure/azure-functions/install-update-binding-extensions-manual )

Is it possible? Thanks for your help.

If I understood your question, once you add the "Microsoft.Azure.WebJobs.Extensions.Storage" nuget package it will be part of your project. Whenever you run dotnet restore, it will add the package to your container.

If you want to add it to your project in Visual Studio, use package manager:

Install-Package Microsoft.Azure.WebJobs.Extensions.CosmosDB -Version 3.0.4

Ensure your.csproj file has this package reference in it:

<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.CosmosDB" Version="3.0.4" />

If you need to add it manually, you can do so through Kudu which you access via https://[your-func-hostname].scm.azurewebsites.net - Full instructions here

Adding manually to a deployed docker container can only be achieve when using persistent storage.

You can use an app setting called WEBSITES_ENABLE_APP_SERVICE_STORAGE to control whether or not the /home directory of your app is mapped to Azure Storage. If you need files to be persisted in scale operations or across restarts, you should add this app setting and set it to "true". If you don't require file persistence, you can set this app setting to false.

The absence of this app setting will result in the setting being "true". In other words, if this app setting does not exist in your app, you will see the /home directory mapped to Azure Storage. The app setting will be missing if you created your app while Web App for Containers was in public preview or if someone has deleted the app setting.

Keep in mind that if you enable App Service Storage, when an Azure Storage changeover occurs (which does happen periodically), your site will restart when the storage volume changes.

Note: If App Service Storage is not enabled, any files written into the /home folder will not be persisted across instances (in the case of a scale out) or across restarts.

Even if storage persistence is disabled, the /home directory will be mapped to Azure Storage in the Kudu (Advanced Tools) container. That way, the /home/LogFiles directory will persist between restarts and scale out operations in the Kudu container. Therefore, if you need to get Docker logs or other logs, always use the Kudu Bash console instead of using SSH to access your app's container. (See this for more information on how to get the latest Docker logs from Kudu.)

Note: If you set this app setting on an Azure App Service on Linux app using a built-in image, it will have no impact.

Source: https://blogs.msdn.microsoft.com/waws/2017/09/08/things-you-should-know-web-apps-and-linux/#NoStorage

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM