Len*_*y D 2 c# docker kubernetes azure-functions keda
我正在尝试将 Azure Functions 应用程序发布到 Kubernetes,但运行此命令时出现以下错误
func kubernetes deploy --name my-function-api --namespace default --registry mycontainerregistry/docker-azure-function --csharp
无法找到项目根目录。期望在项目根目录中找到 host.json、local.settings.json 之一。`
这是我的 docker 文件
FROM mcr.microsoft.com/dotnet/sdk:3.1 AS installer-env
COPY . .
RUN cd /MyFunctionApp.Api && \
mkdir -p /home/site/wwwroot && \
dotnet publish *.csproj --output /home/site/wwwroot
COPY /MyFunctionApp.Api/host.json /home/site/wwwroot
COPY /MyFunctionApp.Api/local.settings.json /home/site/wwwroot
# To enable ssh & remote debugging on app service change the base image to the one below
# FROM mcr.microsoft.com/azure-functions/dotnet:2.0-appservice
FROM mcr.microsoft.com/azure-functions/dotnet:3.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]
Run Code Online (Sandbox Code Playgroud)
正如你所看到的,我尝试添加以下几行
COPY /MyFunctionApp.Api/host.json /home/site/wwwroot
COPY /MyFunctionApp.Api/local.settings.json /home/site/wwwroot
Run Code Online (Sandbox Code Playgroud)
但这似乎也没有帮助,所以不确定我需要做什么才能使其正常工作?任何帮助,将不胜感激。
好吧,明白了这一点。Azure Functions 不读取local.settings.json
或settings.json
在容器中运行时,这些键需要设置为环境变量。
您需要将其放在local.settings.json
运行的同一文件夹中func kubernetes deploy
,该文件夹将生成一个 yaml 文件,其中包含启动时传递到容器中的设置。
注意:这似乎不适用于设置CORS
。我有一个新问题,这里是 AKS 集群内 Azure Functions 的 CORS 问题
归档时间: |
|
查看次数: |
2261 次 |
最近记录: |