Azure Mobile Services: How to see the WebConfig file published
Scope
This article explains how to see the Web.Config file on a published Azure Mobile Services site.
Introduction
In Azure Mobile Services it is possible to have different environments, for example an application will often require both “Dev” and “Prod” environments to allow separation between development and live. Numerous separate environments can be maintained using conditional directives and transform files as described in the article Azure Mobile Services: How to creating a Dev and Prod environments:
http://s23.postimg.org/ggpw0nrzv/ams11.pngFigure 1: Transform Files
During deployment, the Web.Config is transformed based on build configuration, as seen in Figure 2:
http://s20.postimg.org/qyb5qnsv1/Web_Config_2.jpgFigure 2: Publishing
The Azure Portal allows creation of Azure Mobile Services, monitoring, configure and it is possible to see the logs. The Web.Config file is of course quite important and you cannot easily view this. This article explains how you can.
Description
Kudu is the engine behind Git deployments in Azure Web Sites, and Azure Mobile Services is not more than an extension of ASP.Net WebApi, this way the deployment used in both is the same.
The Kudu project is available in GitHub in this reference github.com/projectkudu/kudu which wiki has all documentation about it. For each Azure Mobile Service is possible to access its Kudu using something like https://<Azure Mobile Service Base Url>.scm.azure-mobile.net and the Azure Portal credentials.
Let’s use the Menu App Sample, where the Azure Mobile Service is defined in https://mymenuapp.azure-mobile.net/ to access the Kudu page we need to use https://mymenuapp.scm.azure-mobile.net. We then see something like Figure 3:
http://s20.postimg.org/rvhkzj4d9/Web_Config_3.jpg
Figure 3: Kudu main page
To see the Web.Config we need to click in “Debug Console” and choose one of the options - let’s choose “PowerShell” as below:
http://s20.postimg.org/klw0gtpst/Web_Config_4.jpgFigure 4: Selecting PowerShell
The following page will be showed:
http://s20.postimg.org/oxkm5twpp/Web_Config_5.jpgFigure 5: PowerShell page
In console do “cd site” and “cd wwwroot” as following in Figure 6:
http://s20.postimg.org/em89d650d/Web_Config_6.jpgFigure 6: Navigate to wwwroot
At the end, we see the following table
Now it is possible to download, edit or delete the WebConfig file, using the options in the left. If we click in edit we will have something like:
http://s20.postimg.org/gumfuic4d/Web_Config_8.jpgFigure 7: WebConfig File
Conclusion
In conclusion, we can conclude to get the Web.Config in Azure Mobile Service server is very simple and in some cases can be useful, but a developer should carefully consider any changes as they are likely to impact production.