Reputation: 97
Trying to deploy Isolated Azure Func from VS2022 I already created brand new func in Azure portal and scaffolded new function in VS2022 Func works locally. I am deploying using consumption plan and to windows
Getting this when publishing:
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"
Nothing helpful in 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.
===================
Output log:
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 file contents:
<?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>
My func project file: 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>
I already tried:
My current settings in configuration:
By the way I am able to deploy created zip with command below using azure cli:
az webapp deployment source config-zip --resource-group yourresourcegroupnameonazure --name yourfunctionappnameonazure --src xxx.zip
None-isolated (in-process) function deploys successfully Any suggestions?
Thank you!
Upvotes: 1
Views: 780
Reputation: 8694
The attempt to publish the ZIP file through https://MYSITE.scm.azurewebsites.net/api/zipdeploy failed with HTTP status code Forbidden.
HTTP status code 403 Forbidden indicates that the server refuses to authorize the request.
This error may occur if the credentials used to authenticate the request do not have sufficient permissions to perform the operation.
Function App=>Configuration=>General Settings
:Once the deployment fails in VS, go to the Function app=>Functions
in portal, click on Refresh and publish again.
Clean and re-build the solution.
Create a new function app via Visual Studio during Publish Profile creation and deploy the function.
I have created a .NET 6 Isolated Azure function and deployed to Azure through Visual Studio.
.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>
Application Settings of function 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>
Deployment Status in KUDU site:
References:
Upvotes: 0