unable to deploy to azure web app services
Asked Answered
S

4

6

I am experiencing a weird error when trying to build a continous pipeline build from github to azure app services. Ive done deploys before from other accounts and they work just fine, the difference between those accounts and this one is its a personal account and its on a free-tier. the others are not. but still i am receiving an unathorized error

Run azure/webapps-deploy@v2
  with:
    app-name: contactKeeper
    slot-name: Production
    publish-profile: ***
    package: .
Package deployment using ZIP Deploy initiated.
Error: Failed to deploy web package to App Service.
Error: Deployment Failed with Error: Error: Failed to deploy web package to App Service.
Unauthorized (CODE: 401)
App Service Application URL: http://contactkeeper.azurewebsites.net

Does anyone know why i am receiving this issue?

Speculative answered 10/10, 2021 at 1:16 Comment(0)
S
1

The only thing I can think of is the reason for this issue, was, i was hitting some kind of wall with the amount of app resources i was using, i used a paid subscription tier in a different account and was able to successfully deploy the app to that location. the app still returns this error if i try to deploy it to the free tiered account.

the answer: Upgrade from a base free tier to a pay tiered.

Speculative answered 15/10, 2021 at 18:56 Comment(3)
This answer is not correct. It works when you changed the tier is because it cleared a bug from the app services (<= you got a new "storage" by switching to a new tier). I do believe that you have deployed at least one time using VS which will generate the issue. I got a ticket with MS Support and we have successfully reproduced the issue. It's related to a config log file. So when you "restart" your app service, it is based on the package named indicated on that config log file (i forgot the filename on the app service). If you clear up that package name on that file, it will work properlyLucchesi
@Lucchesi its possible? its been a few years since i've had to deal with an issue like this, my app deployment through azure is now more robust and scalable, and i havent had an issue like this since.Speculative
it's more robust and scalable because you are using a paid-tier :D. If it doesn't find "WEBSITE_RUN_FROM_PACKAGE=1" in the env var, it will try to find packagepath.txt and packagename.txt under the path /home/data/sitepackage to know which zip file is the target. so your initial issue is not because you used free tier but because there is an issue with which package to use (at least on Linux env) so the workaround is: 1. Set WEBSITE_RUN_FROM_PACKAGE=1. 2. Remove packagepath.txt file manually. Normally for dev env, i don't like run from package as sometime i want to debug directly w/o redeployLucchesi
H
7

This is one of the two Azure & Kudu 401 threads in SO and it didn't help me much, so here are my 2 cents.

My setup:
I am using Azure Function Apps in combination with GitHub Actions.

Stack trace:

Successfully parsed SCM credential from publish-profile format.
Using SCM credential for authentication, GitHub Action will not perform resource validation.
Error: Execution Exception (state: ValidateAzureResource) (step: Invocation)
Error:   When request Azure resource at ValidateAzureResource, Get Function App Settings : Failed to acquire app settings from https://<scmsite>/api/settings with publish-profile
Error:     Failed to fetch Kudu App Settings.
Unauthorized (CODE: 401)

Interpretation:
Your credentials have been retrieved and processed but they are wrong.

Solution:
Copy the publish profile from the Azure Function App dashboard. enter image description here

Paste it in the associated GitHub Actions Secret. enter image description here Those two should match.

Henrieta answered 11/10, 2022 at 14:54 Comment(2)
This worked for me. I am using Azure Function Apps in combination with GitHub Actions. Amazing. Thanks!Escutcheon
For some reason I had disabled Get publish profile but I was able to get it from Deployment Center -> Manage publish profile -> Download publish profileDiaphoretic
Q
5

Thank you vincent1173 posting your suggestion as an answer to help other community members.

Error: Deployment Failed with Error: Error: Failed to deploy web package to App Service. Unauthorized (CODE: 401)

For this error , you can try to set an application setting WEBSITE_WEBDEPLOY_USE_SCM and value true in Azure Portal and retry the deployment after 1 min.

Here is the step : Go to Azure portal>App service> Configuration> Add application setting and save it.

enter image description here

For more information please refer this Microsoft Documentation : Deploy an Azure Web App

Quinary answered 11/10, 2021 at 10:32 Comment(3)
thanks for the reply. Can you please tell me a little bit more in detail of what this actually does?Speculative
This is an environment variable ,which we need to specify while deployment of an application. You can refer this MS DOC : learn.microsoft.com/en-us/azure/app-service/…Quinary
I looked over the documentation you referred to but that doesn't necessarily answer my question. My question was how does this environment variable fix my problem? Why does specifying this variable in app settings will it cause it to no longer give me this flag? The documentation you provided doesn't give any details on thisSpeculative
H
4

If you encounter this issue, please verify your Basic Authentication Settings. Follow the instructions below:

  1. Navigate to the Deployment Center and inspect for any red flag messages as shown below,

Warning Message

  1. Click the Red flag notification and it will navigate you to the Configuration section. Then click the General Settings Tab.

  2. In the Platform settings, ensure that both Basic Auth Publishing Credentials and FTP state configurations match as indicated below.

Platform Settings

  1. Save the configuration and try to re-run the flow.
Hart answered 19/1 at 18:17 Comment(0)
S
1

The only thing I can think of is the reason for this issue, was, i was hitting some kind of wall with the amount of app resources i was using, i used a paid subscription tier in a different account and was able to successfully deploy the app to that location. the app still returns this error if i try to deploy it to the free tiered account.

the answer: Upgrade from a base free tier to a pay tiered.

Speculative answered 15/10, 2021 at 18:56 Comment(3)
This answer is not correct. It works when you changed the tier is because it cleared a bug from the app services (<= you got a new "storage" by switching to a new tier). I do believe that you have deployed at least one time using VS which will generate the issue. I got a ticket with MS Support and we have successfully reproduced the issue. It's related to a config log file. So when you "restart" your app service, it is based on the package named indicated on that config log file (i forgot the filename on the app service). If you clear up that package name on that file, it will work properlyLucchesi
@Lucchesi its possible? its been a few years since i've had to deal with an issue like this, my app deployment through azure is now more robust and scalable, and i havent had an issue like this since.Speculative
it's more robust and scalable because you are using a paid-tier :D. If it doesn't find "WEBSITE_RUN_FROM_PACKAGE=1" in the env var, it will try to find packagepath.txt and packagename.txt under the path /home/data/sitepackage to know which zip file is the target. so your initial issue is not because you used free tier but because there is an issue with which package to use (at least on Linux env) so the workaround is: 1. Set WEBSITE_RUN_FROM_PACKAGE=1. 2. Remove packagepath.txt file manually. Normally for dev env, i don't like run from package as sometime i want to debug directly w/o redeployLucchesi

© 2022 - 2024 — McMap. All rights reserved.