failed with HTTP status code 'Unauthorized'.

Jassim Al Rahma 1,541 Reputation points
2023-05-14T19:52:08.6466667+00:00

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

.NET
.NET
Microsoft Technologies based on the .NET software framework.
3,525 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,155 questions
0 comments No comments
{count} votes

3 answers

Sort by: Most helpful
  1. moo2u2 46 Reputation points
    2024-04-23T11:14:22.2566667+00:00

    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.

    User's image

    1 person found this answer helpful.
    0 comments No comments

  2. 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

  3. Grmacjon-MSFT 17,136 Reputation points
    2023-05-17T19:33:05.5966667+00:00

    Hi @Jassim Al Rahma

    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