Attempt to publish the ZIP file through Azure Function App Site URL failed with HTTP status code Unauthorized

Viewed 1617

I have created an Azure Function in VS 2019 and want to deploy it from VS 2019. While trying to deploy I am getting below error: The attempt to publish the ZIP file through failed with HTTP status code Unauthorized. I have tried following options:

  1. Created Function App from portal and then publish the Function project from VS2019
  2. Created the Function App from VS2019 and trying to publish the function

None of the options is working. I am always getting same UNAUTHORIZED error.

1 Answers

I tried to reproduce your issue. Yes, We will get Unauthorized if the specific key is not passed to the URL after deploying to azure functions.

Every Function app has some authorization levels:

  • Anonymous
  • Function
  • Admin
  • System
  • User

They are defined in authLevel attribute in function.json code file.

enter image description here

I tried with Admin authLevel to run the function and to get the 401 unauthorized, I given the function key in the function app URL:

enter image description here

Now I have Host (_master) key to the function app URL along with the query string parameter (name), then the result is: enter image description here

Hence, We get unauthorized when suitable keys are not passed to the function app URL. Based on the authLevel, we have to pass the keys in the URL.

Anonymous - no authentication is required. Any valid HTTP request passes Function - host (master) and function keys. Admin - requires a host key for authorization. System - requires the master key of a function app for authorization. User - requires a valid authentication token.

Function, Admin & System authorization level are key based.

For more information on authorization level usage in function app, refer here.

Related