In my case there is a new toggle under "Configuration" which disables "SCM Basic Auth Publishing Credentials" - as it was set to "Off" and I needed to toggle it "On". I discovered this when trying to "Download publish profile" from the Overview tab of the web app, and it failed.
failed with HTTP status code 'Unauthorized'.
Hi,
Why I suddenly started getting this error:
/Users/jassim/Projects/OneID/One ID API/Controllers/Account.cs(116,9,116,15): warning CS0162: Unreachable code detected
/usr/local/share/dotnet/sdk/7.0.203/Sdks/Microsoft.NET.Sdk.Publish/targets/PublishTargets/Microsoft.NET.Sdk.Publish.ZipDeploy.targets(55,5): error : The attempt to publish the ZIP file through 'https://oneid.scm.azurewebsites.net/api/zipdeploy' failed with HTTP status code 'Unauthorized'.
13 Warning(s)
1 Error(s)
How can I fix it, please?
Thanks,
Jassim
5 answers
Sort by: Most helpful
-
-
Matthew Hess 5 Reputation points
2024-09-22T17:02:59.8766667+00:00 There are several ways to publish an Azure Function to an Azure Function App. This answer applies specifically to publishing via Visual Studio 2022 (screen shots from version `7.9.2)
As mentioned above, make sure Basic SCM Auth Publishing is set to On and Restart to app. Then try this...
- In the Azure Portal, your Azure Function App, Overview, click Get publish profile.
- In Visual Studio, right-click your function and choose Publish to bring up the publish wizard. Click New Profile and then choose Import Profile
- Click Next and then Browse... to select the file you downloaded in step 1. Complete the wizard and publish the app. This worked for me.
- In the Azure Portal, your Azure Function App, Overview, click Get publish profile.
-
Deleted
This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.
Comments have been turned off. Learn more
-
Grmacjon-MSFT 18,816 Reputation points
2023-05-17T19:33:05.5966667+00:00 We are sorry to hear you're facing this issue. Can you please give us more details about what you were trying to achieve before you got this error?
There are two separate issues happening here.
- The first one (warning CS0162: Unreachable code detected):
The warning message means that you have some code in your file "Account.cs" that is unreachable, meaning it will never be executed. To fix this warning, you need to locate the line number mentioned in the warning (116,9,116,15) and examine the code in that range.
- The second error message (The attempt to publish the ZIP file through 'https://oneid.scm.azurewebsites.net/api/zipdeploy' failed with HTTP status code 'Unauthorized')
This error is due to a permission issue. It basically means that the deployment failed because the user account that you are using to publish the ZIP file does not have the necessary permissions to deploy to the specified Azure Web App.
you can fix this error by making sure the user account that you are using to publish the ZIP file has the necessary permissions to deploy to the Azure Web App. You can do this by checking the deployment credentials for the Azure Web App in the Azure portal and ensuring that the user account that you are using has the necessary permissions.
Hope that helps. please let us know if you have further questions
-
Euan Gordon 1 Reputation point
2025-02-13T10:47:29.9833333+00:00 Same issue here.
Made a new function project that does almost nothing, but can't publish it using VS2022.
In the Azure Portal I have enabled SCM, downloaded a Publish Profile, some info I can gather shown below.
I don't understand how bad this is, like making a brand new function and wanting to publish it is almost impossible using VS2022. I have managed to publish using the command line only using
func azure functionapp publish CompassCoreFunctions-Ais-Test
Publish has encountered an error. 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\Euan Gordon\AppData\Local\Temp\tmp5900.tmp" The attempt to publish the ZIP file through https://compasscorefunctions-ais-test.scm.azurewebsites.net/api/zipdeploy failed with HTTP status code NotFound. 2>Publishing C:\Users\Euan Gordon\source\repos\CompassCore-Functions\CompassAis\obj\Release\net8.0\PubTmp\CompassAis - 20250213104253944.zip to https://compasscorefunctions-ais-test.scm.azurewebsites.net/api/zipdeploy... 2>C:\Users\Euan Gordon\.nuget\packages\microsoft.azure.functions.worker.sdk\1.16.2\build\Microsoft.Azure.Functions.Worker.Sdk.Publish.ZipDeploy.targets(47,5): Error : The attempt to publish the ZIP file through https://compasscorefunctions-ais-test.scm.azurewebsites.net/api/zipdeploy failed with HTTP status code NotFound.