I have this custom section in my web.config
<defaultUserAccounts>
<userAccount email="x#x.com" password="xxx" />
<userAccount email="y#y.com" password="yyy" />
</defaultUserAccounts>
I host my web app on Azure and I want to be able to add new userAccount in the Azure App Settings.
I tried with:
defaultUserAccounts.userAccount.email / z#z.com
defaultUserAccounts.userAccount.password / zzz
OR
defaultUserAccounts:userAccount:email / z#z.com
defaultUserAccounts:userAccount:password / zzz
But it doesnt work. I can read the web.config custom section in localhost, but not when the app is hosted.
Could you help me?
You can only write the app settings using the management API of Azure. See here for an example using the Fluent SDK. Otherwise the settings are read-only from within the app.
https://stackoverflow.com/a/50116234
If you don't want to configure app setting in the Configuration you could follow this tutorial:Configure app settings configure it under tag <appSettings> in Web.config, but the values in App Service override the ones in Web.config.
The below is my test:
And use System.Configuration.ConfigurationManager.AppSettings["testkey"] to get the value, the below page is get the value with host in Azure.
Hope this could help you.
Related
According to the documentation you need to add the following to your applicationInsights.config file to enable full SQL logging:
<Add Type="Microsoft.ApplicationInsights.DependencyCollector.DependencyTrackingTelemetryModule, Microsoft.AI.DependencyCollector">
<EnableSqlCommandTextInstrumentation>true</EnableSqlCommandTextInstrumentation>
</Add>
But in my ASP.NET app running on .NET Framework 4.7.2 hosted in an Azure App Service I'm enabling/configuring Application Insights via code:
TelemetryConfiguration.Active.DisableTelemetry = false;
TelemetryConfiguration.Active.InstrumentationKey = setting.ApplicationInsightsInstrumentationKey;
How can I enable this setting via code?
P.S.: The settings in the Web App are correctly enabled.
It seems even if AI is enabled via code it picks up the settings from the config file.
I added it to my applicationInsights.config and it seems to work now.
I deployed a website in https://pokegotool.azurewebsites.net.
However, when I use a browser to access it and read the browser console, it told that the "Content/pre-css/styles.less" file is inaccessible (error code 404).
I build the web site locally in IIS and it had no such problem as the file is loaded successfully. I am sure that the file exists in Azure deployment place.
This URL is ZIP archived project: https://www.mediafire.com/file/i6745pz5j43cw2z/RangeGen.zip/file
Feel free to use it.
Is this an error from Azure or from my project itself? How could I fix it?
I have deployed your project and met the same issue . Basically , it is due to that Azure app service IIS server have not mapped correct MIME type for .less files by default.
To solve this issue , just adding a map record in your web.config file as below :
<system.webServer>
<staticContent>
<mimeMap fileExtension=".less" mimeType="text/plain" />
</staticContent>
</system.webServer>
It works on my app service , try it here : https://rangegen20190902101335.azurewebsites.net/Content/pre-css/styles.less
Pls mark me if it solves your issue : )
I'm currently working on a .net core application that uses a azure service bus queue.
We are restricted to using AMQP over websockets and are behind a corporate proxy.
The QuietClient class does not provide anyway to set proxy information in any of it's constructors and we get a
"Cannot connect to remote server" error when we attempt to write a message to the queue.
The exact same code works when I use it from home - not behind a proxy!
In regular .net bypassing a proxy could be achieved by adding to default proxy configuration in the web.config.
<defaultProxy enabled="true" useDefaultCredentials="false">
<proxy usesystemdefault="True" proxyaddress="http://someAddredd:8888" />
......
</defaultProxy>
Because this is a .net core application the app doesn't use a web.config file for it's configuration.
When deployed to IiS a light weight web.Config file is created to allow the IIS to integrate with core's kestrel web server. However, adding the bypass proxy info to this does not work.
Any help would be much appreciated!
I'm having some trouble accessing the AWS credentials in the SDK Store, but it seems to only be a problem when running under IIS. If I hit the same code by invoking an NUnit test with ReSharper the dependency injection works and the S3 client is able to authenticate.
IAmazonS3 s3Client = new AmazonS3Client();
Has anyone else run into this problem? How were you able to get the dependency injection to work?
[Edit]
The credential file approach has been recommended for use with IIS because the SDK Store encrypts the credentials differently for each user. I can only get a credentials file to work if I hard-code the path in the appSettings which I do not want to do.
Where would the SDK look for the credentials file besides the below paths?
C:\Users\<IIS_app_name>\.aws\credentials
C:\Users\<my_domain_user>\.aws\credentials
The question was answered under Pavel's answer, but I'll post an answer to make the information easier to consume. You can specify the credentials file location in the webLocal.config (I wasn't able to get it to work without that). When the app is deployed, the credentials file location will be an invalid path, and the SDK will fail over to using the IAM role for the EC2 instance.
webLocal.config
<?xml version="1.0"?>
<appSettings>
<!-- AWS -->
<add key="AWSProfilesLocation" value="C:\Users\<IIS_app_name>\.aws\credentials" />
<add key="AWSRegion" value="us-west-2" />
<add key="S3Bucket" value="bucket." />
</appSettings>
The dependency injection will work when you instantiate a client without arguments.
IAmazonS3 s3Client = new AmazonS3Client();
The SDK Store saves the credentials under the C:\Users\<username>\AppData\Local\AWSToolkit folder, so unless IIS is being run under the same account as the NUnit tests, IIS will not be able to access the same credentials.
This blog discusses the various options for storing and using credentials. In your case, it looks like a better option would be to use the credentials file.
The deployment requirements for my app (a windows service written in C#) state the presence of a Proxy server.
From my interaction with the person who will install my app:
1. His company blocks access to internet via the proxy
2. He needs to provide the path to the proxy script in his IE Config.
3. He also needs to input a user-name/password.
My application needs to access a publicly hosted WebService. In preparation, I sent him a test Winform app. In the app.config file I used the setting mentioned in this post .NET client app: how to reach Web Services in case of proxy?
However, it did not work. I customized the proxy setting in App.config as per his IE settings, yet nothing seemed to work.
I don't want to hard-code the proxy settings in my app using the System.Net classes. There is no doubt in my mind that I want to use the config file.
So, I want to install a proxy on a VPC image and try and get my application to run.
My question:
1. What is a good proxy that I can install on my VM (windows only - no linux/squid pls.) that will replicate the behaviour that I mentioned in 2 & 3 above.
2. In case it is of interest, the proxy settings I used was:
<system.net>
<defaultProxy >
<proxy usesystemdefault= “False“ proxyaddress=“http://10.1.10.10:8080“ bypassonlocal=“True“ />
</defaultProxy>
</system.net>
Assuming that the system will read the settings from IE, I also tried
<proxy autoDetect="true" />
It did not work.
Pls. let me know if my requirements are unclear.
The open source squid proxy has Windows binaries.
If you have a Windows Server OS in you VPC, you could try out Microsoft's very own ISA Server. There's a 180-day trial version here.