Data Dad
Data Dad

Reputation: 161

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

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.

Upvotes: 16

Views: 19714

Answers (7)

Sean
Sean

Reputation: 15164

After changing the settings, I had to re-download and re-import the publish profile. Only then did it work.

Upvotes: 0

Krishna
Krishna

Reputation: 51

enter image description here

Do the below steps

  1. Open app function
  2. Left side under settings >> Click Configuration
  3. Go to the General setting tab
  4. Chage radio button from off to on for both SCM and FTP Basic Auth Pub.
  5. Save
  6. try to publish again

Upvotes: 2

ServletException
ServletException

Reputation: 239

Had this error in IntelliJ rider after authenticating with Azure Toolkit.

Setting basic auth to be on in my App Service configuration section worked.

Upvotes: 0

Mousavi
Mousavi

Reputation: 175

I know this is an old question. However, today I faced this problem and I found out the resolution is this:

there is no need to change Basic Auth Publishing status leave it to On. change FTP state to All allowed.

enter image description here

Upvotes: 10

whatever
whatever

Reputation: 3687

I was facing the same failure when trying to publish a .NET Azure Function app from Visual Studio and I discovered that the Deploy ZIP file with REST APIs requires basic authentication to be turned on. So, in the Azure Portal for your Azure Function app go to Configuration and then to General Settings and turn on basic authentication.

enter image description here

Upvotes: 27

Roy
Roy

Reputation: 91

The following setting needs to be set to On. Once it has been, you can publish. enter image description here

Upvotes: 9

anon
anon

Reputation:

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.

Upvotes: -1

Related Questions