具有非匿名 authLevel 的 Docker 中的 Http 触发 Azure 函数 [英] Http Trigger Azure Function in Docker with non anonymous authLevel

查看:9
本文介绍了具有非匿名 authLevel 的 Docker 中的 Http 触发 Azure 函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 Docker 容器中的 Http 触发 Azure 函数.到目前为止,我找到的所有设置此设置的教程和指南都将 Azure 函数配置为 authLevel" 设置为 anonymous.

I am playing around with an Http Triggered Azure Functions in a Docker container. Up to now all tutorials and guides I found on setting this up configure the Azure Function with the authLevel" set to anonymous.

在仔细阅读 这个博客 之后,这似乎是可能的(虽然很棘手) 还可以配置其他身份验证级别.不幸的是,承诺的后续博客文章还没有(还)被写出来.

After reading this blog carefully it seems possible (although tricky) to also configure other authentication levels. Unfortunately the promised follow up blogpost has not (yet) been written.

谁能帮我澄清一下我将如何进行和设置?

Can anyone help me clarify on how I would go about and set this up?

推荐答案

要控制 Function host 在启动时使用的主密钥 - 而不是生成随机密钥 - 准备我们自己的 host_secrets.json 文件,例如

To control the master key the Function host uses on startup - instead of generating random keys - prepare our own host_secrets.json file like

{
    "masterKey": {
        "name": "master",
        "value": "asGmO6TCW/t42krL9CljNod3uG9aji4mJsQ7==",
        "encrypted": false
    },
    "functionKeys": [{
        "name": "default",
        "value": "asGmO6TCW/t42krL9CljNod3uG9aji4mJsQ7==",
        "encrypted": false
    }]
}

然后将此文件输入到 Function 主机的指定 secrets 文件夹中(Dockerfile):

and then feed this file into the designated secrets folder of the Function host (Dockerfile):

对于 V1 函数(假设您的运行时根目录是 C:WebHost):

...
ADD host_secrets.json C:\WebHost\SiteExtensions\Functions\App_Data\Secrets\host.json
...

对于 V2 函数(假设您的运行时根目录是 C: untime):

...
ADD host_secret.json C:\runtime\Secrets\host.json

USER ContainerAdministrator
RUN icacls "c:
untimesecrets" /t /grant Users:M
USER ContainerUser

ENV AzureWebJobsSecretStorageType=files
...

功能键可用于调用受保护的函数,例如 .../api/myfunction?code=asGmO6TCW/t42krL9CljNod3uG9aji4mJsQ7==.

The function keys can be used to call protected functions like .../api/myfunction?code=asGmO6TCW/t42krL9CljNod3uG9aji4mJsQ7==.

主密钥可用于调用 Functions Admin API密钥管理 API.

The master key can be used to call Functions Admin API and Key management API.

我的博客我描述了带来V1及更高版本的整个过程V2 Functions 运行时到 Docker 容器中并在 Service Fabric 中托管这些容器.

In my blog I describe the whole journey of bringing V1 and later V2 Functions runtime into Docker containers and host those in Service Fabric.

适用于 Windows 上的 V3 函数:

ENV FUNCTIONS_SECRETS_PATH=C:Secrets
ENV AzureWebJobsSecretStorageType=Files
ADD host_secrets.json C:\Secrets\host.json

适用于 Linux 上的 V3 函数:

RUN mkdir /etc/secrets/
ENV FUNCTIONS_SECRETS_PATH=/etc/secrets
ENV AzureWebJobsSecretStorageType=Files
ADD host_secrets.json /etc/secrets/host.json

这篇关于具有非匿名 authLevel 的 Docker 中的 Http 触发 Azure 函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆