We have two asp.net web applications (Two asp web projects in one solution)
Both are hosted on IIS. Both apps expose WCF services.
Those services read and write files to the file system. In each service, we determine where to read and write files from using :
HttpContext.Current.Server.MapPath(".")
So in this way, each service writes and read from the folder of it's web app.
We want the services to read and write from the same place (We want this to happen in development and production ).
Is there a way to achieve this ?
Just an idea, define the same path in web.config of both web applications. Use the defined path instead of getting Server.MapPath(".").
web.config:
<configuration>
<appSettings>
<add key="Path" value="c:\\somefolder\\"/>
</appSettings>
</configuration>
C#:
ConfigurationManager.AppSettings["Path"]
Related
I need two applications hosted on two Azure App Services to access one specific file(.xml). What is my best option? What are my options?
I am trying to implement: Share authentication cookies among ASP.NET apps.
Both apps have to access the COMMON KEY RING FOLDER with the key file.
One of the applications is ASP.NET MVC, the second one is ASP.NET Core, both run on .NET472
Edit:
I need a file to be accessible for two .net applications running as appservices. I will use C#/F# to read/write the file. The file must be on Azure.
I recomend you to use an Azure Blob Storage and read the xml from there.
https://learn.microsoft.com/en-us/azure/storage/blobs/storage-quickstart-blobs-dotnet
I have recently migrated from Azure Cloud Service to Azure Web App. Earlier I use to Disable the rapidFailProtection from my Webrole class. After the migration to Web App, I have remove the webrole class and added the code of rapidFail in the Application startup routine of the global.asax file. But it gave an error:
role discovery data is unavailable
at the following line:
Dim mainSite = serverManager.Sites(RoleEnvironment.CurrentRoleInstance.Id + "_Web")
How can I achieve the same functionality for my Azure Web App?
How can I achieve the same functionality for my Azure Web App?
As far as I know, the rapidFailProtection is a application pool setting which you could set it in the ApplicationHost.config file in app service.
So if you want to set the rapidFailProtection to false in the azure web app, I suggest you could try to use XML Document Transformation (XDT) declarations to transform the ApplicationHost.config file in your web app in Azure App Service.
I suggest you could try below steps to add the XDT file to your web app to change the ApplicationHost.config settings.
1.Access the KUDU console.Find the Advanced Tools in DEVELOPMENT TOOLS click go.
2.Click dubug console's cmd.
3.Locate the D:\home\site and add below xdt file.
Notice: Change the name as your web app service name
<?xml version="1.0" encoding="utf-8"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<system.applicationHost>
<applicationPools>
<add name="testforapppool" xdt:Locator="Match(name)">
<failure rapidFailProtection="false" xdt:Transform="InsertBefore(/configuration/system.applicationHost/applicationPools/add[(#name='testforapppool')]/*[1])" />
</add>
<add name="~1testforapppool" xdt:Locator="Match(name)">
<failure rapidFailProtection="false" xdt:Transform="InsertBefore(/configuration/system.applicationHost/applicationPools/add[(#name='~1testforapppool')]/*[1])" />
</add>
</applicationPools>
</system.applicationHost>
</configuration>
Image:
Besides, you could also install Site Extension called IIS Manager which lets you very easily create XDT files simply by editing your applicationhost.config.
More details, you could refer to this article:
Azure App Service web app advanced config and extensions
Xdt transform samples
Is it possible to a custom configuration section inside of an Azure Cloud Service Configuration, the same way you would in a regular ASP.NET website?
I.e in a regular ASP.NET site your Web.Config would have something like this:
<configuration>
<configSections>
<section name="myCustomConfig" type="MyNamespace.MyType" />
</configSections>
<myCustomConfig someProperty="someValue" />
</configuration>
How is this done in Cloud Services and shared across multiple different roles?
At this time I do not believe this is possible. There is a post for it on user voice you can vote up: http://www.mygreatwindowsazureidea.com/forums/169386-cloud-services-web-and-worker-role-/suggestions/459944-enable-custom-configuration-sections-in-csdef-cscf.
As a way around this you could put configuration into a file that is stored in BLOB storage. On start up, or when it is needed, all instances could then go pull the file to get the configuration. To deal with changes to the configuration you could either have the instances pulling the configuration from time to time as a refresher, or you could tap into the environment changed event in RoleEntryPoint that is used to detect changes to the Service Configuration. Add a setting to the service configuration that is a version number of your shared config file or something, just anything that could be modified to trigger the RoleEnvironment.Changing event.
I am trying to understand how I can configure my .NET website to display each domain or groups of domains as Applications in the New Relic RPM console.
There is an article explaining here how to do it for PHP
https://newrelic.com/docs/php/per-directory-settings
Applications can be named individually in the application's web config file. This is done by adding the following to the <appSettings> element:
<appSettings>
<add key="NewRelic.AppName" value="my_web_app" />
<add key="NewRelic.AgentEnabled" value="true" />
</appSettings>
Multiple instances of an application can report to the same name in the New Relic UI by giving each application instance the same name as shown above.
Of course, you can separate applications by giving them different names.
You can use this naming feature to group application instances by name as you need. Your application instances can be running on the same server, on different servers, or on a mix of these.
See this page for some additional information on application naming.
Note that you can also enable/disable monitoring of an application or application instance using the NewRelic.AgentEnabled key in the app settings section.
At this time, the .NET agent doesn't support differentiating which
application to report to based on the hostname of each request.
https://discuss.newrelic.com/t/report-websites-or-applications-running-in-the-same-iis-app-pool-as-different-new-relic-applications/36828
UPDATE December 2017: Please go to the URL above and vote for the feature if you think this feature would be useful.
I would like to deploy my MVC3 app to Azure using multiple physical sites of the same app.
It's great that I can use the sites element in ServiceDefinition.csdef to do this.
But I want each of the sites to connect to a different database. The connection string is in the web.config. Is there an easy way to do this, besides logging into the vm and changing it by hand?
You could register a startup task to go and modify/move the web.config files when the VM starts up. It's a bit messy, but cleaner than doing it by hand!
http://msdn.microsoft.com/en-us/library/windowsazure/gg456327.aspx
[Answer to your comment] - With Windows Azure (actually with any PaaS solution) The first rule of thumb is that when the role starts all the configuration should be ready and the second rule of thumbs is that nothing should be done in VM through RDP access, because changes will not persist. Due to this required configuration either deployed in Azure Package or modified directly from start up task.
[Answer to your question]
In Windows Azure you can run multiple sites within one Web Role however they all should share the same main web.config because multiple sites are running within one Web Role. Here is how you can do it:
http://msdn.microsoft.com/en-us/library/windowsazure/gg433110.aspx
Now as your requirement is to have multiple databases, so in your web.config you can add multiple database connection string as below:
$
<ConnectionString>
<Add name="DB1" connectionString="Data Source=DS1.........."/>
<Add name="DB2" connectionString="Data Source=DS2.........."/>
</ConnectionString>
once you have above, in your ASP.NET code you can enumerate these connection strings and use with specific sites as described in the given example:
http://www.dotnetspark.com/kb/780-how-to-use-multiple-database-connection.aspx
Finally, you can add multiple sites with your web role during development and can also have specific DB connection specified in web.config so I dont think there is any need to use startup task at all or do something in VM, unless i am missing something here.