Can't publish Function App: "SCM Basic Auth Publishing" keeps resetting to Off

Momo Jeng 10 Reputation points Microsoft Employee
2024-06-21T19:37:25.75+00:00

I am trying to publish an Azure Function from Visual Studio, and keep gettng errors "The attempt to publish the ZIP file through [URL] failed with HTTP status code unauthorized." I also sometimes (but not always) get a warning message saying "Basic auth is disabled for the host [Function App name]"

Other sites indicated that I could fix this by going to the Function App under Settings > Configuration and then the "General settings" tab, and setting "SCH Basic Auth Publishing" to "On." If I do this and hit "Save," I get a popup saying "Successfully updated web app settings." However, attempts to publish still fail.

If I go back to the Function App Configuration page and refresh it typically (but not 100% of the time), I find that the SCM Basic Auth Publishing toggle has switched back to "Off." But even if this hasn't happened right away, if I wait a little bit, I eventually always find that it's gone back to "Off."

What makes this toggle back? Is there any way I can stop this or publish my function anyway?

I have Contributor and Owner roles for the Function App.

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
5,593 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Oren Horowitz 10 Reputation points Microsoft Employee
    2024-09-12T05:56:49.99+00:00

    This is how I resolved the issue in my side: I found out that we had a policy on our subscription that prevented us from creating a storage account which allows local authentication (key based), and this is why every time I tried to change the configuration, it went back off.

    The issue is that by default, when you create a function app, it is being created with a storage account, that the authentication between it and the function app is key based. So, the resolution was to create a function app that will communicate with the storage account based on MSI (and not key based), and this unblocked me from deploying the function app using Azure CLI, or Visual Studio.

    In order to do it, I followed this documentation: Use managed identity instead of AzureWebJobsStorage to connect a function app to a storage account - Microsoft Community Hub

     

    Note that the most critical part in order to succeed this is to uncheck the Add an Azure Files connection box, when you create the function app, otherwise, this will not work (as explained in the documentation above)

    1 person found this answer helpful.
    0 comments No comments

  2. Oren Horowitz 10 Reputation points Microsoft Employee
    2024-09-12T06:32:33.02+00:00

    This is how I resolved the issue in my side: I found out that we had a policy on our subscription that prevented us from creating a storage account which allows local authentication (key based), and this is why every time I tried to change the configuration, it went back off.

    The issue is that by default, when you create a function app, it is being created with a storage account, that the authentication between it and the function app is key based. So, the resolution was to create a function app that will communicate with the storage account based on MSI (and not key based), and this unblocked me from deploying the function app using Azure CLI, or Visual Studio.

    In order to do it, I followed this documentation: Use managed identity instead of AzureWebJobsStorage to connect a function app to a storage account - Microsoft Community Hub

     

    Note that the most critical part in order to succeed this is to uncheck the Add an Azure Files connection box (see screenshot below), when you create the function app, otherwise, this will not work (as explained in the documentation above):
    User's image

    1 person found this answer helpful.
    0 comments No comments

  3. Pinaki Ghatak 5,575 Reputation points Microsoft Employee
    2024-07-01T08:38:26.6133333+00:00

    Hello @Momo Jeng

    This issue could be caused by a few different factors, such as a misconfiguration in your Azure Function App or a problem with your Visual Studio installation.

    However, one possible solution is to try enabling Basic Authentication for your Function App through the Azure Portal. Here are the steps to do so:

    1. Go to the Azure Portal and navigate to your Function App.
    2. Under Settings, select "Authentication / Authorization".
    3. Toggle "App Service Authentication" to On.
    4. Under "Action to take when request is not authenticated", select "Log in with Azure Active Directory".
    5. Save your changes. After enabling Basic Authentication through the Azure Portal, try publishing your Function App again from Visual Studio.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.