Can you update the web.config file for an Azure web app without redeploying?
Asked Answered
S

4

23

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?

Stretto answered 25/10, 2016 at 5:18 Comment(0)
P
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.

Pushcart answered 25/10, 2016 at 5:31 Comment(8)
what about complex web.config settings like rewrite rules? I don't think those can be modified in Portal Application Settings.Huber
If its not exposed in the Application settings UI, then use the App Service EditorPushcart
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.Vansickle
@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.Pushcart
Thx. Just used App Service Editor to get my MSIE 11 browser happy. In web.config I was able to add <add name="X-UA-Compatible" value="IE=edge" /> in an httpProtocol/customHeaders nodeAllianora
What this is great for is temporarily turning on having it display errors on RESTful requests.Gumboil
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.Wain
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, and even though the files aren't marked (e.g. by attrib) as having the RO flag set, they effectively are.Yb
C
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

Callisto answered 25/10, 2016 at 9:42 Comment(0)
J
0

Another option is to actually update your deployment pipeline to make any type of modifications you need to your .config files. Here is the link to StackOverflow thread that describes in detail how to perform this.

Jilljillana answered 8/8 at 11:18 Comment(0)
U
-1

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.

Unrepair answered 27/11, 2019 at 21:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.