尝试从 VS2022 部署隔离的 Azure Func 我已经在 Azure 门户中创建了全新的函数,并在 VS2022 中搭建了新函数 Func 在本地工作。我正在使用消费计划和 Windows 进行部署
发布时得到这个:
Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
A diagnostic log has been written to the following location:
"C:\Users\User\AppData\Local\Temp\tmpA19A.tmp"
tmpEB87.tmp 没有任何帮助:
3/8/2024 7:38:58 PM
System.AggregateException: One or more errors occurred. ---> Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
--- End of inner exception stack trace ---
---> (Inner Exception #0) Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details. <---
Microsoft.WebTools.Shared.Exceptions.WebToolsException: Publish has encountered an error. We were unable to determine the cause of the error. Check the output log for more details.
===================
输出日志:
2>A publish profile with the name 'ZipDeploy' was not found in the project. Set the PublishProfile property to a valid file name.
2>WorkerExtensions -> C:\Users\User\AppData\Local\Temp\farqnhib.ee0\publishout\
2>Publishing C:\Temp\isolated\app\obj\Release\net6.0\PubTmp\isolated - 20240308193855433.zip to https://MYSITE.scm.azurewebsites.net/api/zipdeploy...
2>The attempt to publish the ZIP file through https://MYSITE.scm.azurewebsites.net/api/zipdeploy failed with HTTP status code Forbidden.
ZipDeploy.pubxml 文件内容:
<?xml version="1.0" encoding="utf-8"?>
<!--
https://go.microsoft.com/fwlink/?LinkID=208121.
-->
<Project>
<PropertyGroup>
<WebPublishMethod>ZipDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>https://MYSITE.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>false</LaunchSiteAfterPublish>
<ResourceId>/subscriptions/MY_SUBSCRIPTION/resourceGroups/MY_GROUP/providers/Microsoft.Web/sites/MY_SITE</ResourceId>
<UserName>$mysite1</UserName>
<_SavePWD>true</_SavePWD>
<PublishUrl>https://MYSITE.scm.azurewebsites.net/</PublishUrl>
</PropertyGroup>
</Project>
我的 func 项目文件:isolated.csproj
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>isolated_test_app</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.2" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
我已经尝试过:
顺便说一句,我可以使用 azure cli 通过以下命令部署创建的 zip:
az webapp deployment source config-zip --resource-group yourresourcegroupnameonazure --name yourfunctionappnameonazure --src xxx.zip
非隔离(进程内)功能部署成功 有什么建议吗?
谢谢!
尝试通过 https://MYSITE.scm.azurewebsites.net/api/zipdeploy 发布 ZIP 文件失败,HTTP 状态代码为“禁止”。
HTTP 状态码 403 Forbidden 表示服务器拒绝授权该请求。
如果用于验证请求的凭据没有足够的权限来执行操作,则可能会发生此错误。
Function App=>Configuration=>General Settings
中打开基本身份验证发布状态:一旦在VS中部署失败,请转到门户中的
Function app=>Functions
,再次单击刷新并发布。
清理并重新构建解决方案。
在创建发布配置文件期间通过 Visual Studio 创建一个新的函数应用并部署该函数。
我创建了一个 .NET 6 隔离的 Azure 函数并通过 Visual Studio 部署到 Azure。
.csproj:
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.4" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.1.0" />
</ItemGroup>
功能App的应用设置:
zip Deploy.pubxml:
<Project>
<PropertyGroup>
<WebPublishMethod>ZipDeploy</WebPublishMethod>
<PublishProvider>AzureWebSite</PublishProvider>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<SiteUrlToLaunchAfterPublish>https://<functionappname>.azurewebsites.net</SiteUrlToLaunchAfterPublish>
<LaunchSiteAfterPublish>false</LaunchSiteAfterPublish>
<ResourceId>/subscriptions/subscription_id/resourcegroups/resourcegroupname/providers/Microsoft.Web/sites/functionappname</ResourceId>
<UserName>$functionappname</UserName>
<_SavePWD>true</_SavePWD>
<PublishUrl>https://functionappname.scm.azurewebsites.net/</PublishUrl>
</PropertyGroup>
</Project>
KUDU 站点中的部署状态:
参考资料:
尝试通过 https://xxx.scm.azurewebsites.net/api/zipdeploy 发布 ZIP 文件失败,HTTP 状态代码为 Forbidden。