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:\Users\uname\AppData\Local\AzureFunctionsTools 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:

func azure functionapp publish <functionappname>. AlsoSCM basic authsetting should be turned on during deployment. It turns off automatically sometimes.