在 Linux 容器上触发 Azure 函数 HTTP - 函数不起作用 404 [英] Azure function HTTP triggered on linux container - function not working 404

查看:16
本文介绍了在 Linux 容器上触发 Azure 函数 HTTP - 函数不起作用 404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被困住了,也许你可以帮助我.(更新:经过调查,我确实知道它不起作用,因为构建/发布后 Azure 功能的 wwwroot 文件夹是空的.主要问题是为什么)

我正在尝试使用 Azure Container Registry (Linux) 发布 Azure Function 这一步我认为我成功了.我确实创建了 CI/CD 管道,并且所有内容都已正确发布.

当我进入我的天蓝色函数主页时:

函数本身的开头.这没什么花哨的,因为我只是想测试 CI/CD,所以它是 AF 模板.我只是将授权更改为匿名(以排除身份验证问题):

 [FunctionName("MyAzureFunctionName")]公共静态异步任务<IActionResult>跑([HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,ILogger 日志){log.LogInformation("C# HTTP 触发函数处理了一个请求.运行!");字符串名称 = req.Query["name"];string requestBody = await new StreamReader(req.Body).ReadToEndAsync();动态数据 = JsonConvert.DeserializeObject(requestBody);名字=名字??数据?.名称;返回名称!= null?(ActionResult)new OkObjectResult($"Hello, {name}"): new BadRequestObjectResult("请在查询字符串或请求正文中传递一个名称");}

所以我很高兴 - 对吧?不,因为它不起作用.我正在尝试通过 HTTP 请求触发此功能:

当我使用新的 Azure 功能管理体验"时,也会出现同样的情况

[更新 04.05.2020 11:40]

提供有关此案的更多信息.下面是 docker 镜像的样子:

#请参阅 https://aka.ms/containerfastmode 以了解 Visual Studio 如何使用此 Dockerfile 构建映像以加快调试速度.FROM mcr.microsoft.com/azure-functions/dotnet:3.0 作为基础工作目录/app曝光 80FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build工作目录/src复制 ["BuildChat/BuildChat.csproj", "BuildChat/"]复制 ["MyFunctionName/MyFunctionName.csproj", "MyFunctionName/"]运行 dotnet restore "MyFunctionName/MyFunctionName.csproj"复制 ..WORKDIR "/src/MyFunctionName"运行 dotnet build "MyFunctionName.csproj" -c Release -o/app/buildFROM 构建 AS 发布运行 dotnet 发布MyFunctionName.csproj"-c 发布 -o/app/publish从基础 AS 最终工作目录/app复制 --from=publish/app/publish .ENV AzureWebJobsScriptRoot=/app

这是我正在使用的构建管道:

- 阶段:BuildMyAzureFunctiondisplayName:构建并推送 MyAzureFunction 阶段工作:- 工作:建造显示名称:构建水池:vmImage: $(vmImageName)脚步:- 任务:Docker@2displayName:构建镜像并将镜像推送到容器注册表输入:容器注册:$(dockerRegistryServiceConnection)存储库:$(imageRepositoryMyAzureFunction)命令:'buildAndPush'Dockerfile: $(dockerfilePathAzureMyAzureFunction)标签: |$(标签)

我不知道我还能给你什么:)

可能是 Azure 门户中的容器设置:

以及最新 docker 版本的日志:

2020-05-04 09:32:32.693 信息 - 由于 AppSettingsChange 和 isMainSite = True 正在回收容器2020-05-04 09:32:32.777 信息 - 拉取图像:myAcrContainer.azurecr.io/mobile/myAzureFunction:20200503.112020-05-04 09:32:33.829 信息 - 20200503.11 从移动/myAzureFunction 中提取2020-05-04 09:32:33.832 信息 - 摘要:sha256:688090984dbc5d257b7d4eefff886affa451c59407edd46792dfc81726f393ec2020-05-04 09:32:33.832 信息 - 状态:myAcrContainer.azurecr.io/mobile/myAzureFunction:20200503.11 的图像是最新的2020-05-04 09:32:33.835 信息 - 拉取图像成功,所用时间:0 分 1 秒2020-05-04 09:32:33.959 信息 - 站点的启动容器2020-05-04 09:32:33.961 信息 - docker run -d -p 7287:80 --name myAzureFunction_1_84dd4d10 -e WEBSITE_CORS_ALLOWED_ORIGINS=https://functions.azure.com,https://functions-staging.azure.com,https://functions-next.azure.com -e WEBSITE_CORS_SUPPORT_CREDENTIALS=False -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=myAzureFunction -e WEBSITE_AUTH_ENABLED=False -e PORT=80 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOST.NAME=myAzureFunction净 -e WEBSITE_INSTANCE_ID=8da8a02a13a3cdde53ad6aafcd4eb717ca00dd6bc65ff07378d74a0cd859e1c0 -e HTTP_LOGGING_ENABLED=1 myAcrContainer.azurecr.io/mobile/myAzureFunction:20200503.112020-05-04 09:32:39.421 信息 - 站点的启动容器2020-05-04 09:32:39.422 信息 - docker run -d -p 1500:8081 --name myAzureFunction_1_84dd4d10_middleware -e WEBSITE_CORS_ALLOWED_ORIGINS=https://functions.azure.com,https://functions-staging.azure.com,https://functions-next.azure.com -e WEBSITE_CORS_SUPPORT_CREDENTIALS=False -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=myAzureFunction -e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOST_TANCE_ID=myAzureFunction_azurewebsites.net8da8a02a13a3cdde53ad6aafcd4eb717ca00dd6bc65ff07378d74a0cd859e1c0 -e HTTP_LOGGING_ENABLED=1 appsvc/middleware:2001061754/Host.ListenUrl=http://0.0.0.0:8081/Host.DestinationHostUrl=http://172.1680=true680.2020-05-04 09:32:44.658 信息 - 为站点 myAzureFunction 向容器 myAzureFunction_1_84dd4d10 发起预热请求2020-05-04 09:33:00.400 信息 - 等待对容器 myAzureFunction_1_84dd4d10 的预热请求的响应.经过时间 = 15.7420671 秒2020-05-04 09:33:16.088 信息 - 等待对容器 myAzureFunction_1_84dd4d10 的预热请求的响应.经过时间 = 31.4308809 秒2020-05-04 09:33:33.284 信息 - 等待对容器 myAzureFunction_1_84dd4d10 的预热请求的响应.经过时间 = 48.6269148 秒2020-05-04 09:33:56.001 信息 - 站点 myAzureFunction 的容器 myAzureFunction_1_84dd4d10 已成功初始化并准备好为请求提供服务.2020-05-04 09:33:56.004 信息 - 为站点 myAzureFunction 向容器 myAzureFunction_1_84dd4d10_middleware 发起预热请求2020-05-04 09:34:04.506 信息 - 站点 myAzureFunction 的容器 myAzureFunction_1_84dd4d10_middleware 已成功初始化并准备好为请求提供服务.2020_05_04_RD501AC582A899_easyauth_docker.log:2020_05_04_RD501AC582A899_default_docker.log:2020-05-04T09:21:14.187664147Z 托管环境:生产2020-05-04T09:21:14.187744046Z 内容根路径:/app2020-05-04T09:21:14.187750446Z 现在收听:http://[::]:802020-05-04T09:21:14.187754446Z 应用程序已启动.按 Ctrl+C 关闭.2020-05-04T09:33:49.229983024Z 托管环境:生产2020-05-04T09:33:49.232401696Z 内容根路径:/app2020-05-04T09:33:49.232413096Z 现在收听:http://[::]:802020-05-04T09:33:49.232417396Z 应用程序已启动.按 Ctrl+C 关闭.

[更新 04.05.2020 15:55]

我检查了部署中心,看起来还可以:

但是因为我要发布 3 个 thigns(1 个 SignalR 集线器和 2 个 azure 函数 - 当然两者都不工作")我在想 - 也许它正在以某种方式混合(在这个 azure 函数应用程序上 - 实际上 SignalR 正在发表了吗?

我确实检查了这个发布任务日志(假设发布了 MyAzureFunction)并且一切看起来都正确(日志中到处都是我的 MyAzureFunction):

这是我的发布管道的样子:

这里是持续部署触发配置:

这里是第 2 阶段(用于发布 azure 功能)预部署设置:

最后,发布步骤本身(虽然我已经发布了它的 YAML 版本.老实说 - 一切都检查过了.图像/应用名称没有不匹配)

[更新 04.05.2020 16:15]

所以现在我 100% 知道发生了什么.在没有任何错误/警告的情况下成功发布后,azure 函数就是空的 :)

我已经使用高级工具检查了 wwwroot 的内容(在转到

所以它为什么不起作用是可以理解的 :) 主要问题是 到底发生了什么"?:)

我确实尝试在部署中心同步代码(如@djsly 建议的那样),但它不起作用(可能是因为它是由容器管理的)但是当我尝试同步时我正在添加一条消息:

[更新 05.05.2020 00:18]

我确实连接到 Azure 容器注册表并下载了映像,假设是在 Azure 中运行此 Azure 函数的映像.

所以我确实跑了:

docker login myAcrContainer.azurecr.iodocker pull myAcrContainer.azurecr.io/mobile/myAzureFunction:20200503.11docker run -it --rm -p 31234:80 myAcrContainer.azurecr.io/mobile/myAzureFunction:20200503.11

我确实点击了

以下是计划详情:

现在是免费试用版(正如他们在我创建它时提出的那样)这可能是原因吗?他们不应该禁止某事而不是允许然后破坏某事吗?;)

解决方案

对于任何有类似问题的人

我得到了或多或少的信息问题的根本原因是什么".微软支持人员联系了我并指出,这是 docker 文件的问题.

他指出了两点:我将 AzureWebJobsScriptRoot 更改为 /app.他声称这可能是它在本地机器上而不是在 AzureWebJobsScriptRoot/home/site/wwwroot

的 Azure 门户上工作的原因

关于这句话的两个有趣的事实:

1) 创建这个 dockerfile 的不是我(我离菜鸟还很远)这是 MS(插件)的功能,它允许您右键单击项目并选择 Add->Docker support

这是这个功能:https://docs.microsoft.com/pl-pl/visualstudio/containers/overview?view=vs-2019

2) 到底谁会在工作环境中造成如此差异,以至于在本地 docker 上运行的某些东西在 Azure 门户上的 docker 上无法运行 - 这太疯狂了 :)

他建议我学习本教程:https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image?tabs=bash%2Cportal&pivots=programming-语言-csharp

并使用此命令:

func init LocalFunctionsProject --worker-runtime dotnet --docker

它会创建这样的 docker 文件(或多或少)

FROM microsoft/dotnet:2.2-sdk AS installer-env复制 ./src/dotnet-function-app运行 cd/src/dotnet-function-app &&mkdir -p/home/site/wwwroot &&dotnet publish *.csproj --output/home/site/wwwroot# 启用 ssh &应用服务上的远程调试将基础图像更改为以下图像# FROM mcr.microsoft.com/azure-functions/dotnet:2.0-appservice来自 mcr.microsoft.com/azure-functions/dotnet:2.0ENV AzureWebJobsScriptRoot=/home/site/wwwroot AzureFunctionsJobHost__Logging__Console__IsEnabled=true复制 --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]

这里最重要的是 - 它适用于 Azure Function 2,我使用的是 Azure Function 3.不过,我确实更改了图像版本以适应版本 3,并且我确实对其进行了扩展以涵盖这样一个事实,即我必须构建引用的库.但它仍然不工作:)(意思是,它在本地工作,但在 Azure 门户上不工作)

我将仅根据 docker 的问题创建新的 SOF.但我留下了这条评论 - 也许它会对某人有所帮助.

[更新 13.05.2020]

适用于寻找问题根本原因的任何人.如果您要查找 Azure 功能上的 404 问题 - 请在此处查看:Linux 容器上 Azure 函数的 Docker 问题 - 函数丢失导致函数运行时出现 404

I am stuck and maybe you can help me out. (Update: After investigation, I do know that it is not working because the wwwroot folder for the Azure function after build/release is empty. The main question is why)

I am trying to publish Azure Function using Azure Container Registry (Linux) This step I think I am successful. I did create CI/CD pipeline and everything is being published correctly.

When i enter my azure function main page like: https://myAzureFuncion.azurewebsites.net/ (it is only example)

i do see:

At the begining the function itself. It is nothing fancy, as i just wanted to test the CI/CD so it is the AF template. I just did changed the Auhtorization to Anonymous (to exlude issue with the authentication):

        [FunctionName("MyAzureFunctionName")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request. Runned!");

            string name = req.Query["name"];

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data = JsonConvert.DeserializeObject(requestBody);
            name = name ?? data?.name;

            return name != null
                ? (ActionResult)new OkObjectResult($"Hello, {name}")
                : new BadRequestObjectResult("Please pass a name on the query string or in the request body");
        }

So i good to go - right? No, as it is not working. I am trying to trigget this function by HTTP request:

https://myAzureFuncion.azurewebsites.net/api/MyAzureFunctionName?name=Mark

And I keep getting 404 Not Found. I did check it with Postman: The same (previously with function authorization i did try with ?code=(code_in_host) and with headers x-functions-key. All the time the same info --> 404 Not Found)

It is as this function was not existing.

Of course, when I run it locally (using docker for windows) everything is working correctly. I am running:

https://localhost:some_port/api/MyAzureFunctionName?name=Mark

And I am receiving proper answer.

Can you point me what to check and how to diagnose the issue here? I've entered the App Insights Live Metrics --> but no request is being noted.

How to diagnose the issue here?

[UPDATE 04.05.2020 01:35]

Here is how my release pipeline looks like for this component in YAML

steps:
- task: AzureFunctionAppContainer@1
  displayName: 'Azure Function App on Container Deploy: MyFunctionName'
  inputs:
    azureSubscription: MySubscription
    appName: MyFunctionName
    imageName: 'myAcrContainer.azurecr.io/mobile/MyFunctionName:$(Build.BuildNumber)'

I saw also one weird thing in Azure Portal for this Azure function. When i go to functions menu - there is information, that there is none:

The same shows up, when i use the "new Azure Function management experience"

[UPDATE 04.05.2020 11:40]

Putting more info on the case. Here is how docker image looks like:

#See https://aka.ms/containerfastmode to understand how Visual Studio uses this Dockerfile to build your images for faster debugging.

FROM mcr.microsoft.com/azure-functions/dotnet:3.0 AS base
WORKDIR /app
EXPOSE 80

FROM mcr.microsoft.com/dotnet/core/sdk:3.0-buster AS build
WORKDIR /src
COPY ["BuildChat/BuildChat.csproj", "BuildChat/"]
COPY ["MyFunctionName/MyFunctionName.csproj", "MyFunctionName/"]
RUN dotnet restore "MyFunctionName/MyFunctionName.csproj"
COPY . .
WORKDIR "/src/MyFunctionName"
RUN dotnet build "MyFunctionName.csproj" -c Release -o /app/build

FROM build AS publish
RUN dotnet publish "MyFunctionName.csproj" -c Release -o /app/publish

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENV AzureWebJobsScriptRoot=/app

And here is the build pipeline that i am using:

- stage: BuildMyAzureFunction
  displayName: Build and push MyAzureFunction stage
  jobs:  
  - job: Build
    displayName: Build
    pool:
      vmImage: $(vmImageName)
    steps:
    - task: Docker@2
      displayName: Build and push image to container registry
      inputs:
        containerRegistry: $(dockerRegistryServiceConnection)
        repository:  $(imageRepositoryMyAzureFunction)
        command: 'buildAndPush'
        Dockerfile: $(dockerfilePathAzureMyAzureFunction)
        tags: |
          $(tag)

I do not know what more i can give you :)

Maybe container settings in Azure Portal:

And logs from latest docker release:

2020-05-04 09:32:32.693 INFO  - Recycling container because of AppSettingsChange and isMainSite = True
2020-05-04 09:32:32.777 INFO  - Pulling image: myAcrContainer.azurecr.io/mobile/myAzureFunction:20200503.11
2020-05-04 09:32:33.829 INFO  - 20200503.11 Pulling from mobile/myAzureFunction
2020-05-04 09:32:33.832 INFO  -  Digest: sha256:688090984dbc5d257b7d4eefff886affa451c59407edd46792dfc81726f393ec
2020-05-04 09:32:33.832 INFO  -  Status: Image is up to date for myAcrContainer.azurecr.io/mobile/myAzureFunction:20200503.11
2020-05-04 09:32:33.835 INFO  - Pull Image successful, Time taken: 0 Minutes and 1 Seconds
2020-05-04 09:32:33.959 INFO  - Starting container for site
2020-05-04 09:32:33.961 INFO  - docker run -d -p 7287:80 --name myAzureFunction_1_84dd4d10 -e WEBSITE_CORS_ALLOWED_ORIGINS=https://functions.azure.com,https://functions-staging.azure.com,https://functions-next.azure.com -e WEBSITE_CORS_SUPPORT_CREDENTIALS=False -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=myAzureFunction -e WEBSITE_AUTH_ENABLED=False -e PORT=80 -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=myAzureFunction.azurewebsites.net -e WEBSITE_INSTANCE_ID=8da8a02a13a3cdde53ad6aafcd4eb717ca00dd6bc65ff07378d74a0cd859e1c0 -e HTTP_LOGGING_ENABLED=1 myAcrContainer.azurecr.io/mobile/myAzureFunction:20200503.11  

2020-05-04 09:32:39.421 INFO  - Starting container for site
2020-05-04 09:32:39.422 INFO  - docker run -d -p 1500:8081 --name myAzureFunction_1_84dd4d10_middleware -e WEBSITE_CORS_ALLOWED_ORIGINS=https://functions.azure.com,https://functions-staging.azure.com,https://functions-next.azure.com -e WEBSITE_CORS_SUPPORT_CREDENTIALS=False -e WEBSITES_ENABLE_APP_SERVICE_STORAGE=false -e WEBSITE_SITE_NAME=myAzureFunction-e WEBSITE_AUTH_ENABLED=False -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=myAzureFunction.azurewebsites.net -e WEBSITE_INSTANCE_ID=8da8a02a13a3cdde53ad6aafcd4eb717ca00dd6bc65ff07378d74a0cd859e1c0 -e HTTP_LOGGING_ENABLED=1 appsvc/middleware:2001061754 /Host.ListenUrl=http://0.0.0.0:8081 /Host.DestinationHostUrl=http://172.16.2.6:80 /Host.UseFileLogging=true 

2020-05-04 09:32:44.658 INFO  - Initiating warmup request to container myAzureFunction_1_84dd4d10 for site myAzureFunction
2020-05-04 09:33:00.400 INFO  - Waiting for response to warmup request for container myAzureFunction_1_84dd4d10. Elapsed time = 15.7420671 sec
2020-05-04 09:33:16.088 INFO  - Waiting for response to warmup request for container myAzureFunction_1_84dd4d10. Elapsed time = 31.4308809 sec
2020-05-04 09:33:33.284 INFO  - Waiting for response to warmup request for container myAzureFunction_1_84dd4d10. Elapsed time = 48.6269148 sec
2020-05-04 09:33:56.001 INFO  - Container myAzureFunction_1_84dd4d10 for site myAzureFunctioninitialized successfully and is ready to serve requests.
2020-05-04 09:33:56.004 INFO  - Initiating warmup request to container myAzureFunction_1_84dd4d10_middleware for site myAzureFunction
2020-05-04 09:34:04.506 INFO  - Container myAzureFunction_1_84dd4d10_middleware for site myAzureFunction initialized successfully and is ready to serve requests.
2020_05_04_RD501AC582A899_easyauth_docker.log:
2020_05_04_RD501AC582A899_default_docker.log:
2020-05-04T09:21:14.187664147Z Hosting environment: Production
2020-05-04T09:21:14.187744046Z Content root path: /app
2020-05-04T09:21:14.187750446Z Now listening on: http://[::]:80
2020-05-04T09:21:14.187754446Z Application started. Press Ctrl+C to shut down.

2020-05-04T09:33:49.229983024Z Hosting environment: Production
2020-05-04T09:33:49.232401696Z Content root path: /app
2020-05-04T09:33:49.232413096Z Now listening on: http://[::]:80
2020-05-04T09:33:49.232417396Z Application started. Press Ctrl+C to shut down.

[UPDATE 04.05.2020 15:55]

I've checked the deployment center, and its look like it is ok:

But because i am publishing 3 thigns (1 SignalR hub and 2 azure functions - of course both "not working") i am thinking - maybe it is getting somehow mixed (and on this azure function app - in fact SignalR is being published?

I did checked this release task log (which suppose to publish MyAzureFunction) and everything looks correctly (everywhere is my MyAzureFunction in the log):

Here is how my Release pipeline looks like:

And here is Continous deployment trigger configuration:

And here is the stage 2 (for publishing azure function) predeployment settings:

And finally, the release step itself (although I did already posted the YAML version of it. To be hones - everything checks out. There is no missmatch in image/app name)

[UPDATE 04.05.2020 16:15]

So right now for 100% i do know what is going on. After successful release without any errors/warnings, the azure function is simply empty :)

I've checked with advanced tools the content of wwwroot (after going to https://myAzureFunction.scm.azurewebsites.net/wwwroot/)

Here is the result:

So it is quite understandable why it is not working :) The main question is "What the hell happened"?:)

I did try in deployment center to Sync the code (as @djsly suggested) but it is not working (probably because it is being managed by containers) But i am adding a message when I try to sync:

[UPDATE 05.05.2020 00:18]

I did connect to Azure container registry and downloaded the image, that suppose to be the image running behing this Azure function in Azure.

So i did runned:

docker login myAcrContainer.azurecr.io

docker pull myAcrContainer.azurecr.io/mobile/myAzureFunction:20200503.11

docker run -it --rm -p 31234:80 myAcrContainer.azurecr.io/mobile/myAzureFunction:20200503.11

and i did hit http://localhost:31234/api/MyAzureFuncionFuns

and everything works correctly. So it confirm my suspisions, that the image is not being properly "runned" on Azure function on Azure portal.

The question is: Am i doing something wrong - or is it an Azure bug?

There was a question regarding my App Service Plan. Here how it looks like (during Azure function creation):

And here are the plan details:

It is a free trial right now (as they proposed it while I was creating it) Could that be the reason? Shouldn't they disallow something instead of allowing and then breaking things ?;)

解决方案

For anyone having similar issues

I got more or less information "what is the root cause" of the problem. MS Support guy contacted me and pointed me out, that this is an issue with the docker file.

He pointed out two things: I am changing AzureWebJobsScriptRoot to /app. He claimed that this could be the reason why it is working on the local machine and not on Azure Portal where AzureWebJobsScriptRoot is /home/site/wwwroot

Two fun facts about this statement:

1) it is not I, who is creating this dockerfile (i am far to rookie) It was the functionality of MS (plugin) which allows you to right-click the project and choose Add->Docker support

This is this functionality: https://docs.microsoft.com/pl-pl/visualstudio/containers/overview?view=vs-2019

2) Who on earth would create such discrepancies in working environments, that something is working on docker locally will not work on docker on Azure Portal - this is crazy :)

He advised me to go with this tutorial: https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image?tabs=bash%2Cportal&pivots=programming-language-csharp

and to use this command:

func init LocalFunctionsProject --worker-runtime dotnet --docker

And it will create such docker file (more or less)

FROM microsoft/dotnet:2.2-sdk AS installer-env

COPY . /src/dotnet-function-app
RUN cd /src/dotnet-function-app && 
    mkdir -p /home/site/wwwroot && 
    dotnet publish *.csproj --output /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:2.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot 
    AzureFunctionsJobHost__Logging__Console__IsEnabled=true

COPY --from=installer-env ["/home/site/wwwroot", "/home/site/wwwroot"]

The most important thing here is - that it is addressed for Azure Function 2, and I am using Azure Function 3. Nevertheless, I did change images version to fit version 3, and I did extend it to cover the fact, that I have to build the referenced library. But it is still not working :) (meaning, it works locally but doesn't work on Azure Portal)

I will create new SOF simply on the matter of docker. But I leave this comment - maybe it will help someone.

[UPDATE 13.05.2020]

For anyone looking for the root cause of the issue. If you will be looking for the problem with 404 on Azure function - please have a look here: Docker issue with Azure Function on Linux container - function missing leading to 404 on function run

这篇关于在 Linux 容器上触发 Azure 函数 HTTP - 函数不起作用 404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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