我试图使用.NET 6和dotnet运行一组Azure函数。在本地运行时,将正确调用Program.cs/Main方法。当发布到Azure时,Program.cs/Main方法永远不会被调用(这会导致失败,因为DI没有初始化)。
我的local.settings.json看起来像:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
"FUNCTIONS_EXTENSION_VERSION": "~4"
}
}在Azure门户上,查看实时流,我可以看到以下内容:
2022-01-06T18:38:22.618Z INFO - Starting container for site
2022-01-06T18:38:22.619Z INFO - docker run -d -p 8081:8081 --name lolnotsofast_0_b59188ad_msiProxy -e WEBSITE_ROLE_INSTANCE_ID=0 -e WEBSITE_HOSTNAME=lolnotsofast.azurewebsites.net -e WEBSITE_INSTANCE_ID=[lots of hex] appsvc/msitokenservice:[some #s]
2022-01-06T18:38:22.619Z INFO - Logging is not enabled for this container.
Please use https://aka.ms/linux-diagnostics to enable logging to see container logs here.
2022-01-06T18:38:28.950Z INFO - Pulling image from Docker hub: mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated5.0-appservice-stage6
2022-01-06T18:38:29.127Z ERROR - DockerApiException: Docker API responded with status code=NotFound, response={"message":"manifest for mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated5.0-appservice-stage6 not found: manifest unknown: manifest tagged by \"4-dotnet-isolated5.0-appservice-stage6\" is not found"}
2022-01-06T18:38:29.128Z WARN - Image pull failed. Defaulting to local copy if present.
2022-01-06T18:38:29.130Z ERROR - Image pull failed: Verify docker image configuration and credentials (if using private repository)
2022-01-06T18:38:41.279Z INFO - Stopping site cca-amznintegration-d-func because it failed during startup.问题的关键似乎是这个容器映像,mcr.microsoft.com/azure-functions/dotnet-isolated:4-dotnet-isolated5.0-appservice-stage6,是未知的。
我不知道这个名字是怎么被猜到的,也不知道它是什么意思。
对从这里开始有什么想法吗?
谢谢!
发布于 2022-01-07 10:54:49
要从Azure容器注册表中提取码头映像,需要设置环境变量,如下所示:
使用Azure门户的:

使用Azure的: Azure命令az functionapp create,参数如下:
--deployment-container-image-name
--docker-registry-server-password
--docker-registry-server-user

如未解决,请按以下步骤执行:
参考:
https://stackoverflow.com/questions/70612167
复制相似问题