21

I would like to update a database connection string in the web.config file for an application that is currently hosted in Azure as a web app.

Seems that you can RDP into an Azure cloud service role but not a web app. If you can't RDP into an Azure web app, is there another way to update the connection string without redeploying?

dhughes
  • 645
  • 1
  • 7
  • 19

3 Answers3

39

You can use the portal, there is a tool called "App Service Editor" in preview that lets you edit any of the files you've deployed. I do wonder why you want to do this though, it's not considered good practice to modify source files on the fly like this! Config and app settings are exposed via the portal as well and can be modified without dropping to the app service editor tool. (under Settings/Application Settings in portal). Updating these does not update the web.config but will override web.config settings.

Russell Young
  • 2,033
  • 1
  • 14
  • 12
  • 3
    what about complex web.config settings like rewrite rules? I don't think those can be modified in Portal Application Settings. – Mike W Aug 22 '17 at 15:37
  • If its not exposed in the Application settings UI, then use the App Service Editor – Russell Young Aug 23 '17 at 06:37
  • I just updated my connection string in the deployed web.config via VS and also the App Service Editor and these changes were ignored. Only changing the Settings in the portal worked for me. – Daniel Hillebrand Nov 06 '17 at 10:49
  • @DanielHillebrand - I believe the portal settings will override web.config, so if you had the setting in the portal already, changing it in the web.config via app service editor etc will not make a difference. – Russell Young Nov 07 '17 at 11:43
  • Thx. Just used App Service Editor to get my MSIE 11 browser happy. In web.config I was able to add `` in an httpProtocol/customHeaders node – bkwdesign Jun 01 '18 at 20:16
  • What this is great for is temporarily turning on having it display errors on RESTful requests. – David Thielen Jan 11 '19 at 20:39
  • When I edit my Production azure app web.config file and past any code and save the file and again on refresh pasted code disappeared? any logic, site is connected with automatic deployment pipeline. – Saad Awan Sep 28 '20 at 12:34
  • *Warning:* this won't work if your application is configured to `WEBSITE_RUN_FROM_PACKAGE`; [the `wwwroot` directory is mounted from the `.zip` as read-only](https://learn.microsoft.com/en-us/azure/app-service/deploy-run-package#run-the-package), and even though the files aren't marked (_e.g._ by `attrib`) as having the RO flag set, they effectively are. – David Rubin Nov 10 '20 at 19:02
17

As Russell Young said, on Azure portal, we could use App Service Editor that provides an in-browser editing experience for our App code. And we could specify connection string in App settings section to override existing settings.

enter image description here

Besides, we could also to access and update Web.config file (under D:\home\site\wwwroot folder) via Kudu Debug console.

enter image description here

Fei Han
  • 26,415
  • 1
  • 30
  • 41
0

The best practise would be to use a FTP client such as File Zilla, where you can grab it, edit, save and push it back to the host without the hassle of logging into a portal and editing it directly on the server or portal.

Please note that editing a file without backing it up first, and editing a file directly on the server can cause many many problems.

Hounddog75
  • 71
  • 6