简体   繁体   中英

Redeploying azure web app from scratch with ARM template result in 404 Web Site not found

I am using an ARM template to deploy my Azure resource group as part of my release definition. In the case of my Dev environment, I am dropping the entire resource group prior to redeploy it with the ARM template.

During the deployment process, I am testing the API deployed to the staging slot by fetching the version number included in swagger definition. It means at that point my web app is properly reachable. To complete the deployment, I swap my production slot with my staging slot.

After that, when I try to access my web app at https://mywebapp.azurewebsite.net , Chrome stay stuck on a blue page with 404 Web Site not found . 2 solutions are proposed on that page:

  • Ensure custom domain is working properly, but I don't have one on this web app.
  • Flush DNS cache from command line. I did it but without any change after a page refresh.

Any idea of what's going wrong?

This is clearly related to the fact I am dropping the entire resource group to recreate it. I don't see the same behavior in my QA/Prod environment where I don't drop the resource group by default.

Also, I noticed some warning messages during my Dev deployment:

2018-05-11T14:12:07.6188142Z ##[debug][PUT]https://$mywebapp__maintenance:***@mywebapp-maintenance.scm.azurewebsites.net/api/deployments/5921526047927616
2018-05-11T14:12:12.8970287Z ##[debug]updateDeployment. Data: {"statusCode":403,"statusMessage":"Forbidden","headers":{"content-type":"text/html","server":"Microsoft-IIS/10.0","date":"Fri, 11 May 2018 14:12:12 GMT","connection":"close","content-length":"2399"},"body":"<!DOCTYPE html>\r\n<html>\r\n<head>\r\n    <title>Web App - Unavailable</title>\r\n    <style type=\"text/css\">\r\n        html {\r\n            height: 100%;\r\n            width: 100%;\r\n        }\r\n\r\n        #feature {\r\n            width: 960px;\r\n            margin: 95px auto 0 auto;\r\n            overflow: auto;\r\n        }\r\n\r\n        #content {\r\n            font-family: \"Segoe UI\";\r\n            font-weight: normal;\r\n            font-size: 22px;\r\n            color: #ffffff;\r\n            float: left;\r\n            width: 460px;\r\n            margin-top: 68px;\r\n            margin-left: 0px;\r\n            vertical-align: middle;\r\n        }\r\n\r\n            #content h1 {\r\n                font-family: \"Segoe UI Light\";\r\n                color: #ffffff;\r\n                font-weight: normal;\r\n                font-size: 60px;\r\n                line-height: 48pt;\r\n                width: 800px;\r\n            }\r\n\r\n        p a, p a:visited, p a:active, p a:hover {\r\n            color: #ffffff;\r\n        }\r\n\r\n        #content a.button {\r\n            background: #0DBCF2;\r\n            border: 1px solid #FFFFFF;\r\n            color: #FFFFFF;\r\n            display: inline-block;\r\n            font-family: Segoe UI;\r\n            font-size: 24px;\r\n            line-height: 46px;\r\n            margin-top: 10px;\r\n            padding: 0 15px 3px;\r\n            text-decoration: none;\r\n        }\r\n\r\n            #content a.button img {\r\n                float: right;\r\n                padding: 10px 0 0 15px;\r\n            }\r\n\r\n            #content a.button:hover {\r\n                background: #1C75BC;\r\n            }\r\n    </style>\r\n</head>\r\n<body bgcolor=\"#00abec\">\r\n    <div id=\"feature\">\r\n            <div id=\"content\">\r\n                <h1 id=\"unavailable\">Error 403 - This web app is stopped.</h1>\r\n                <p id=\"tryAgain\">The web app you have attempted to reach is currently stopped and does not accept any requests. Please try to reload the page or visit it again soon.</p>\r\n                <p id=\"toAdmin\">If you are the web app administrator, please find the common 403 error scenarios and resolution <a href=\"http://blogs.msdn.com/b/waws/archive/2016/01/05/azure-web-apps-error-403-this-web-app-is-stopped.aspx\" target=\"_blank\">here</a>. For further troubleshooting tools and recommendations, please visit <a href=\"https://portal.azure.com/\">Azure Portal</a>.</p>\r\n        </div>\r\n    </div>\r\n</body>\r\n</html>\r\n"}
2018-05-11T14:12:12.9060930Z ##[warning]Error: Failed to update Deployment status. Error: Forbidden (CODE: 403)
2018-05-11T14:12:12.9071339Z ##[debug]Processed: ##vso[task.issue type=warning;]Error: Failed to update Deployment status. Error: Forbidden (CODE: 403)
...
2018-05-11T14:21:03.6299150Z ##[debug][PUT]https://$mywebapp:***@mywebapp.scm.azurewebsites.net/api/deployments/5921526048459655
2018-05-11T14:21:03.8067460Z ##[debug]updateDeployment. Data: {"statusCode":404,"statusMessage":"Site Not Found","headers":{"content-type":"text/html","server":"Microsoft-IIS/10.0","date":"Fri, 11 May 2018 14:21:03 GMT","connection":"close","content-length":"2778"},"body":"<!DOCTYPE html>\r\n<html>\r\n<head>\r\n    <title>Microsoft Azure Web App - Error 404</title>\r\n    <style type=\"text/css\">\r\n        html {\r\n            height: 100%;\r\n            width: 100%;\r\n        }\r\n\r\n        #feature {\r\n            width: 960px;\r\n            margin: 75px auto 0 auto;\r\n            overflow: auto;\r\n        }\r\n\r\n        #content {\r\n            font-family: \"Segoe UI\";\r\n            font-weight: normal;\r\n            font-size: 22px;\r\n            color: #ffffff;\r\n            float: left;\r\n            margin-top: 68px;\r\n            margin-left: 0px;\r\n            vertical-align: middle;\r\n        }\r\n\r\n            #content h1 {\r\n                font-family: \"Segoe UI Light\";\r\n                color: #ffffff;\r\n                font-weight: normal;\r\n                font-size: 60px;\r\n                line-height: 48pt;\r\n                width: 800px;\r\n            }\r\n\r\n        a, a:visited, a:active, a:hover {\r\n            color: #ffffff;\r\n        }\r\n\r\n        #content a.button {\r\n            background: #0DBCF2;\r\n            border: 1px solid #FFFFFF;\r\n            color: #FFFFFF;\r\n            display: inline-block;\r\n            font-family: Segoe UI;\r\n            font-size: 24px;\r\n            line-height: 46px;\r\n            margin-top: 10px;\r\n            padding: 0 15px 3px;\r\n            text-decoration: none;\r\n        }\r\n\r\n            #content a.button img {\r\n                float: right;\r\n                padding: 10px 0 0 15px;\r\n            }\r\n\r\n            #content a.button:hover {\r\n                background: #1C75BC;\r\n            }\r\n    </style>\r\n    <script type=\"text/javascript\">\r\n        function toggle_visibility(id) {\r\n            var e = document.getElementById(id);\r\n            if (e.style.display == 'block')\r\n                e.style.display = 'none';\r\n            else\r\n                e.style.display = 'block';\r\n        }\r\n    </script>\r\n</head>\r\n<body bgcolor=\"#00abec\">\r\n    <div id=\"feature\">\r\n        <div id=\"content\">\r\n            <h1>404 Web Site not found.</h1>\r\n            <p>You may be seeing this error due to one of the reasons listed below :</p>\r\n            <ul>\r\n                <li>Custom domain has not been configured inside Azure. See <a href=\"https://docs.microsoft.com/en-us/azure/app-service-web/app-service-web-tutorial-custom-domain\">how to map an existing domain</a> to resolve this.</li>\r\n                <li>Client cache is still pointing the domain to old IP address. Clear the cache by running the command <i>ipconfig/flushdns.</i></li>\r\n            </ul>\r\n            <p>Checkout <a href=\"https://blogs.msdn.microsoft.com/appserviceteam/2017/08/08/faq-app-service-domain-preview-and-custom-domains/\">App Service Domain FAQ</a> for more questions.</p>\r\n        </div>\r\n     </div>\r\n</body>\r\n</html>\r\n"}
2018-05-11T14:21:03.8165740Z ##[warning]Error: Failed to update Deployment status. Error: Site Not Found (CODE: 404)
2018-05-11T14:21:03.8166510Z ##[debug]Processed: ##vso[task.issue type=warning;]Error: Failed to update Deployment status. Error: Site Not Found (CODE: 404)
...
2018-05-11T14:22:19.4199443Z ##[debug][PUT]https://$mywebapp__maintenance:***@mywebapp-maintenance.scm.azurewebsites.net/api/deployments/5921526048539418
2018-05-11T14:22:19.6243408Z ##[debug]updateDeployment. Data: {"statusCode":404,"statusMessage":"Site Not Found","headers":{"content-type":"text/html","server":"Microsoft-IIS/10.0","date":"Fri, 11 May 2018 14:22:19 GMT","connection":"close","content-length":"2778"},"body":"<!DOCTYPE html>\r\n<html>\r\n<head>\r\n    <title>Microsoft Azure Web App - Error 404</title>\r\n    <style type=\"text/css\">\r\n        html {\r\n            height: 100%;\r\n            width: 100%;\r\n        }\r\n\r\n        #feature {\r\n            width: 960px;\r\n            margin: 75px auto 0 auto;\r\n            overflow: auto;\r\n        }\r\n\r\n        #content {\r\n            font-family: \"Segoe UI\";\r\n            font-weight: normal;\r\n            font-size: 22px;\r\n            color: #ffffff;\r\n            float: left;\r\n            margin-top: 68px;\r\n            margin-left: 0px;\r\n            vertical-align: middle;\r\n        }\r\n\r\n            #content h1 {\r\n                font-family: \"Segoe UI Light\";\r\n                color: #ffffff;\r\n                font-weight: normal;\r\n                font-size: 60px;\r\n                line-height: 48pt;\r\n                width: 800px;\r\n            }\r\n\r\n        a, a:visited, a:active, a:hover {\r\n            color: #ffffff;\r\n        }\r\n\r\n        #content a.button {\r\n            background: #0DBCF2;\r\n            border: 1px solid #FFFFFF;\r\n            color: #FFFFFF;\r\n            display: inline-block;\r\n            font-family: Segoe UI;\r\n            font-size: 24px;\r\n            line-height: 46px;\r\n            margin-top: 10px;\r\n            padding: 0 15px 3px;\r\n            text-decoration: none;\r\n        }\r\n\r\n            #content a.button img {\r\n                float: right;\r\n                padding: 10px 0 0 15px;\r\n            }\r\n\r\n            #content a.button:hover {\r\n                background: #1C75BC;\r\n            }\r\n    </style>\r\n    <script type=\"text/javascript\">\r\n        function toggle_visibility(id) {\r\n            var e = document.getElementById(id);\r\n            if (e.style.display == 'block')\r\n                e.style.display = 'none';\r\n            else\r\n                e.style.display = 'block';\r\n        }\r\n    </script>\r\n</head>\r\n<body bgcolor=\"#00abec\">\r\n    <div id=\"feature\">\r\n        <div id=\"content\">\r\n            <h1>404 Web Site not found.</h1>\r\n            <p>You may be seeing this error due to one of the reasons listed below :</p>\r\n            <ul>\r\n                <li>Custom domain has not been configured inside Azure. See <a href=\"https://docs.microsoft.com/en-us/azure/app-service-web/app-service-web-tutorial-custom-domain\">how to map an existing domain</a> to resolve this.</li>\r\n                <li>Client cache is still pointing the domain to old IP address. Clear the cache by running the command <i>ipconfig/flushdns.</i></li>\r\n            </ul>\r\n            <p>Checkout <a href=\"https://blogs.msdn.microsoft.com/appserviceteam/2017/08/08/faq-app-service-domain-preview-and-custom-domains/\">App Service Domain FAQ</a> for more questions.</p>\r\n        </div>\r\n     </div>\r\n</body>\r\n</html>\r\n"}
2018-05-11T14:22:19.6268196Z ##[warning]Error: Failed to update Deployment status. Error: Site Not Found (CODE: 404)
2018-05-11T14:22:19.6268967Z ##[debug]Processed: ##vso[task.issue type=warning;]Error: Failed to update Deployment status. Error: Site Not Found (CODE: 404)

The behavior is likely caused by DNS caching on your machine. When you delete and recreate the app, it can end up on a different scale unit with a different IP address. But since you likely just hit the old app that had the same host name, your machine has its IP cached. Workaround:

  • Wait till TTL expires
  • Clear your DNS cache. Can be tricky as there can be caching in some proxies as well
  • If you try from a different machine that didn't cache it, it should work right away (eg try with your phone)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM