Where can I find the web.config in the Azure portal? - azure

Every guide that I see say to do something with the web.config file in Azure. However, no matter how much I Google, there is nowhere to be found the steps that I need to take to find the web.config file. Your help will be highly appreciated :)

There are a few scenarios here. First: when you run on an App Service there is a web.config file. As David Makagon said, it's not accessible through the portal. By default, app services have Kudu available. One of the things this gives you is something like a file explorer. To access Kudu for an App Service with URL https://someapp.azurewebsites.net, go to https://someapp.SCM.azurewebsites.net.
A second thing you could do (which is part of Kudu) is use the App Service Editor. This is an online editor that looks very much like Visual Studio Code. Go to https://someapp.scm.azurewebsites.net/dev.
The third thing: if you have any settings in your web.config that you want to manage without updating the configuration file, have a look at the Application Settings. Any setting that's in there overrides the setting with the same name in the web.config.

Related

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

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?
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.
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.
Besides, we could also to access and update Web.config file (under D:\home\site\wwwroot folder) via Kudu Debug console.
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.

Application manifest file for Azure AD Proxy Applications

I need to edit the application manifest file for an Azure AD Proxy Application but there is no option to download the file from the portal. Does anyone know if a Proxy Application even has a manifest? I would assume so. Is there an equivilent way in Powershell?
The official documentation covers this pretty well including screenshots.
In the Azure AD portal you need to browse to the application, then on the application dashboard you should see the link at the bottom to download the manifest, just like you can see below.

Azure: Is there a way to view deployed files in Azure?

Is there a file "view" available in Azure?
When I log in to Azure to look at a website I've deployed there is no obvious see exactly what files Azure is hosting.
I can see there's the Visual Studio Online option which allows you to live edit your server code but that is more than I need. I just want to be able to check that certain files are deployed and others are not.
If you're just trying to look around, and see the various directories and files in your deployment, you can enter the site's "Kudu" dashboard, using the url format http://<yoursitename>.scm.azurewebsites.net
This will give you a web-based dashboard, including a debug console (web-based) where you can explore your various directories (and the directories will show up visually as well).
More info can be found in this post from the Azure Websites team.
In Visual Studio, in the window "Server Explorer" you click and connect on "Azure".
=> App Service
=> Your site name
=> Files
Here you see all your files and you can edit them directly in Visual Studio.
##### UPDATE 19/08/2019 #####
For some time now, it hasn't worked anymore.... :(
Here is another way to do it: By FTP !
From the Azure portal, in the "App Service" section of your website, go to "Deployment Center" > FTP > Dashboard
There is the FTPS Endpoint => ftp://.....ftp.azurewebsites.windows.net/site/wwwroot
And username, password information.
Install FileZilla Client! (https://filezilla-project.org/)
Enter Host with "FTPS Endpoint" the "username" and "password" and then login quickly!
You can use App Service Editor (previously known as Visual Studio Online). It can be found under your webapp -> Development Tools section in the Azure Portal.
I know this is old, but I just found it, and got some useful tips from it. If you are using an App Service, there is now a browser option to do this as well:
https://YourAppService.scm.azurewebsites.net/dev/wwwroot/
You can get there from the Azure portal, then go to your App service, then scroll down to Development Tools, and click on "App Service Editor".
In VS2017/2019, there's Cloud Explorer to view files in Azure, but each time open folder to view files will invoke connection to cloud, so you have to wait, that's a bit slow.
To open Cloud Explore, Right click on project > Publish > Manage in Cloud Explore, or Top Menu > View > Cloud Explorer.
Yes, you have many options to see that
By clicking Console option (run "dir" command, will list down all files)
By hitting App Service Editor(Preview) option,
Adding to the accepted answer,
you can open an ssh session by going to http://<yoursitename>.scm.azurewebsites.net/webssh/host.
For a long time, I've looked for a linux-style terminal to view my deployed files and environment variables. With this you can view the files, check and set environment variables, make db migrations directly, and a lot more. Hope this is useful.
That could be relevant: AppService->Console
You can use Visual Studio Code and the Azure extension
Since you are using Azure Websites, Azure wants to "manage" it for you, and as a result, you cannot connect to the VM itself. If you were using a Cloud Service, you can obtain the RDP information from the Azure Console and just remote into the machine.
For your situation, you can use FTP as an option. Here is blog that describes one approach:
http://blogs.msdn.com/b/avkashchauhan/archive/2012/06/19/windows-azure-website-uploading-downloading-files-over-ftp-and-collecting-diagnostics-logs.aspx
Here is another option using WebMatrix:
http://www.microsoft.com/web/post/how-to-edit-a-site-hosted-on-windows-azure-with-webmatrix

How to check if code is running on Azure Websites

I knew that we can use RoleEnvironment.IsAvailable to check if code is running in Web/Worker Role. How about Azure Websites?
I tried the above RoleEnvironment code but it always returns false. I need to run some configuration code in Application_Start so I cannot depend on the request stuff.
Any help is appreciated.
This is actually very easy simply check for existence of this environment variable: WEBSITE_SITE_NAME.
!String.IsNullOrEmpty(Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME"))
The content for this will be the name of your site.
To see more environment variable that you have under your site go to the following link: https://{sitename}.scm.azurewebsites.net/Env
You cannot (easily).
With azure Web Sites, your site runs in an IIS. RoleEnvironment will always be false, because it is not initialized there. Look at Azure Web Sites more like a regular hosting. Can you tell if your website is running in XYZ Hosting, or in your own IIS?
One thing that you could consider is the Application Settings in your web.config (yes, the appSettings section) and have some setting indicating whether you run on WebSites or not. Read the full article here about App Settings in Azure WebSites to understand what I mean. In short: if you set a setting value via the portal, it will take precedence over what is in web.config. You can even just set it in the Portal, not having it in your web.config.

Windows Azure Connection Strings - How to Handle Local vs. Production?

I'm in the process of deploying some windows azure projects and I've noticed that it's a bit of a pain to constantly switch my role configuration settings from using LocalStorage to actually use my Windows Azure Storage connection strings.
For local development, I want to use this:
UseDevelopmentStorage=true
But for deployed apps, I want to use something like:
DefaultEndpointsProtocol=https;AccountName=myAccountName;AccountKey=blah
I end up either changing my role's configuration connection strings just before I deploy, or if I forget to do that, I'll attempt to go into the Windows Azure portal and change them (but that usually happens after I watch my role instances start and stop over and over).
I feel like I'm missing something basic, but is there a straight-forward way to have the deployment process switch my role connection settings to use the production storage accounts instead of local storage?
You can use CloudConfigurationManager in Azure SDK 1.7 http://msdn.microsoft.com/en-us/LIBRARY/microsoft.windowsazure.cloudconfigurationmanager
This starts by looking in the ServiceConfiguration.cscfg e.g. ServiceConfiguration.Cloud.cscfg for config setting. If it isn't there it falls back to web.config and app.config
For example
CloudConfigurationManager.GetSetting("StorageConnectionString")
Will look in the appropriate cscfg file for StorageConnectionString setting, then it will search the web.config and then app.config.
If you want to use Visual Studio config transformations, see my answer to the question Panagiotis mentioned.
Switching from one connectionstring to another when moving from development to cloud
Cheers.
If you use CI server you can change the connection string there automatically. Details here.
I've answered a similar question here:
Visual Studio 2010 can apply Debug or Release transformations to Web.config, but what about the Azure settings?

Resources