Azure Funcisolated 发布失败

问题描述 投票:0回答:1

尝试从 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>

我已经尝试过:

  • 在功能设置中禁用/启用 ftp/scm 访问
  • 更新VS2022到最新
  • 检查所有日志 - 也在 scm 上,没有任何帮助
  • 将 WEBSITE_RUN_FROM_PACKAGE 设置为 0,然后再设置回 1
  • 安装/更新 azure-cli 和 azure 核心工具
  • 直接从向导添加发布配置文件并从 Azure 门户下载/添加到 VS
  • 检查解决方案的路径,找到一个删除路径中空格的建议(我的 func 路径:C:\Temp\isolated)
  • 重命名发布配置文件 - 删除名称中的所有空格(我的名字:ZipProfile.pubxml)
  • 将所有功能包/依赖项更新到最新版本
  • 在azure门户中删除了WEBSITE_RUN_FROM_PACKAGE,重置发布配置文件,然后重新启动Func App,然后从VS2022中删除配置文件,从VS2022连接到azure并加载新的发布配置文件 - 没有帮助
  • 以管理员模式启动VS2022

我当前的配置设置:

顺便说一句,我可以使用 azure cli 通过以下命令部署创建的 zip:

az webapp deployment source config-zip --resource-group yourresourcegroupnameonazure --name yourfunctionappnameonazure --src xxx.zip

非隔离(进程内)功能部署成功 有什么建议吗?

谢谢!

azure azure-functions azure-deployment
1个回答
0
投票

尝试通过 https://MYSITE.scm.azurewebsites.net/api/zipdeploy 发布 ZIP 文件失败,HTTP 状态代码为“禁止”。

HTTP 状态码 403 Forbidden 表示服务器拒绝授权该请求。

如果用于验证请求的凭据没有足够的权限来执行操作,则可能会发生此错误。

  • Function App=>Configuration=>General Settings
    中打开基本身份验证发布状态:
  • 检查您是否在函数应用中启用了访问限制并提供公共访问。

enter image description here

  • 一旦在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的应用设置:

enter image description here

  • 通过 Visual Studio 创建了一个新函数:

enter image description here

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>
  • 能够使用消费计划将函数部署到 Azure Function 应用程序 (Windows):

enter image description here

KUDU 站点中的部署状态:

enter image description here

参考资料:

尝试通过 https://xxx.scm.azurewebsites.net/api/zipdeploy 发布 ZIP 文件失败,HTTP 状态代码为 Forbidden

© www.soinside.com 2019 - 2024. All rights reserved.