I am trying to publish a C# Function App to a Linux machine in Azure using VS2022.
The same function App can be published to a Windows machine without any problems.
I have followed the advice of the people answering the question below:
Publish Function App to azure zipdeploy failed with HTTP status code Unauthorized
and I have tried this fix: https://github.com/Azure/azure-functions-dotnet-worker/issues/2502
- Basic Authentication was turned on while deploying the function app.
- Run from package is turned on
- I created a fresh publish profile after checking these settings.
- Disabeled Access-Control-Allow-Credentials
- Removed any allowed Origins
I do get this notification whan trying to publish:
I think this doesnt have anything to do with the authorization for publishing.
I am not sure what to try next.
1
Though you have enabled the SCM basic auth
setting, it turns off automatically sometimes during deployment.
To avoid unauthorized error during deployment, turn off and turn on the SCM basic auth Publishing credentials
setting in Function app=>configuration
and refresh the function app before performing deployment.
You can also enable this setting during function app creation by enabling Basic authentication under Deployment section to avoid deployment errors:
Add SCM_BUILD_DURING_DEPLOYMENT=1
and ENABLE_ORYX_BUILD=true
application settings in the function app’s Environment variables=> App Settings:
Configure Functions_Worker_Runtime
setting according to your function’s runtime.
Delete the C:UsersunameAppDataLocalAzureFunctionsTools
folder, reopen the visual studio IDE and deploy the function again.
I have created an isolated function and deployed to Linux Azure function app.
.csproj:
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.4" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.2.0" />
</ItemGroup>
- Deployed using Visual studio:
As an alternative, try deploying the function using function core tools:
func azure functionapp publish <functionappname>
Portal: