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

6

13

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.

Travesty answered 3/11, 2021 at 21:18 Comment(1)
I am able to deploy the Azure Function using Kudu portal drag and drop method. But publish/deployment from VS is still getting unauthorized error.Travesty
C
21

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

Citron answered 26/9, 2023 at 11:58 Comment(1)
Same error 401 unauthorized. The latest Azure Function Setting Label is "SCM Basic Auth Publishing Credentials". I checked this to ON and Publishing started working.Semester
Z
9

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

Zooid answered 29/6, 2023 at 2:4 Comment(0)
V
9

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

Variform answered 17/1, 2024 at 6:56 Comment(0)
S
2

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
Selfoperating answered 27/5, 2024 at 7:41 Comment(0)
P
0

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

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

Pochard answered 3/5, 2024 at 19:43 Comment(0)
R
-1

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.

Repel answered 9/11, 2021 at 10:14 Comment(6)
Thanks Hari! It is about the deployment or publishing the Azure Function to Azure Function app. While publishing or deploying the function from VS 2019 I am getting this error. I am not sure whether I need some specific permission to publish the Azure function to Azure Function App created by me. I have the permission to create the Azure Function App but is there any other permission which I need to deploy the Azure Function?Travesty
Yes @Deb, We need specific RBAC roles to deploy the azure function. We have 3 roles supported by the Azure functions. Contributor - Create and manage resources of all types Owner - Create and manage resources of all types and has all type of data, delete and roles assignment permissions Reader - Read resources of all types, except secrets. For more details on Azure functions supported roles, refer here. You should have contributor/owner role to create, deploy, delete, edit the azure function.Repel
Thanks Hari! I am able to deploy the Function using Kudu portal drag and drop method. I can also delete the function from Azure portal. I have Signed-In in VS using the same credential and from same VS project I can create the Azure Function App without any issue. But, publish is failing with "UNAUTHORIZED" error. So, I think issue is somewhere else.Travesty
@Deb, That's great to hear from you! Please check the Auth Level during creation of function project also - it will ask you access rights. While creation of azure function, it will give you only 3 access rights like Anonymous, function, and Admin. I given in the above comment how to use access keys based on access level / auth level.Repel
Hari, Appreciate your effort to help me out, but my issue is not about "calling" the function but it is about "deploying" the function from VS2019. The solution provided by you is entirely related to calling the function. So, your solution is not relevant to my question, neither it helped me to resolve the issue or find a workaround. Moreover, the issue still exits for me. I have already mentioned a workaround in my comments which can be helpful for others.Travesty
Hello @Deb - Could you please tell me this, If you'getting this during deployment to azure or while publishing from VS 2019, Could you provide me your function code in the question and mention the steps sequentially how you followed so that I have a chance to deeper look.!Repel

© 2022 - 2025 — McMap. All rights reserved.