I have added azure project in my application and added database connection string values in the settings tag named "MasterDBConnection" under .cscfg file like below:
<Role name="projWorkerRole">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="UseDevelopmentStorage=true" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="true" />
<Setting name="MasterDBConnection" value="Server=u3oUIUIIY1v.database.windows.net;Database=ABCDTest;User ID=11;Password=rCVyqbcmSraLq8bjBXNcYyfPyvNqRu;Trusted_Connection=False;connection timeout=120;Max Pool Size = 500;Pooling = True;" />
<Setting name="StateDBConnection" value="Server=u3oUIUIIY1v.database.windows.net;Database=ASPState;User ID=relate;Password=rCVyqbcmSraLq8bjBXNcYyfPyvNqRu;Trusted_Connection=False;connection timeout=120;Max Pool Size = 500;Pooling = True;" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="abcd" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="MMMMIIBSgIBADAyMB4xHDAaBgNVBAMME1dpbmRvd3MgQXp1cmUgVG9vbHMCEBoNpt+iYi+ZQhZlsYE7ZyIwDQYJKoZIhvcNAQEBBQAEggEAT5HQNweks5KCwtn5inNGrh7w4txgYA75ow/EB5DAmw4AozyKN6FoapXaGyizTU/U7Om+oUbad36IddxNZBp9dDCtS62HlDME8bCCc0tjrvViN0AX8p0l6wlTS0bh8bkZ6R18TbDrR8wnt/BZEkT0a8ynTeY9vYP8GwSNcqIoNSe6dThKeT/vmjqZYjDQrUcUhP7MwwIkhWyMk5svId2mkigHpkwUfCE2QsZh5Yau+eAIhbhy5LKgt/fPZec3fs21JPjZT2yOSQ4Nnagij1ITfG97EQqjl35mq0Es6Jy/BZXNgfF9XWD6zFnAL3t7vQ9Yb2gFRhsLiFh0pFq+E9a8ATAzBgkqhkiG9w0BBwEwFAYIKoZIhvcNAwcECHZXItflnlNUg..." />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="2026-16-27T23:59:59.0000000+05:30" />
</ConfigurationSettings>
<Certificates>
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="04A23427944E036103F686C4DD...." thumbprintAlgorithm="dha1" />
</Certificates>
</Role>
Now when I'm calling the connection string value from .cscfg file it's showing an error.
I'm calling the connection string like below:
string connMaster = RoleEnvironment.GetConfigurationSettingValue("MasterDBConnection");
The error is showing like below:
An exception of type 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironmentException' occurred in Microsoft.WindowsAzure.ServiceRuntime.dll but was not handled in user code
Additional information: error
Related
I have a .NET Azure solution in Visual Studio 2015. The application uses 2 worker roles.
As part of it's functionality, at some point in the build process a couple of dlls are copied in to the cloud project so they end up in the end result.
To make it work I've added the following in "ServiceDefinition.csdef":
<WorkerRole name="SomeProject.Foreman" vmsize="Small">
<Contents>
<Content destination="ClientCustomCode">
<SourceDirectory path="ClientCustomCode" />
</Content>
</Contents>
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
<Setting name="SomeProjectDocumentDBURI" />
<Setting name="SomeProjectAuthorizationKey" />
<Setting name="LogLevel" />
<Setting name="RequestQueue" />
<Setting name="RequestErrorQueue" />
<Setting name="NumberOfConcurrentRequests" />
<Setting name="NumberOfRequestsToReadFromAzureQueue" />
<Setting name="StorageConnectionString" />
<Setting name="SomeProjectPnrHistory" />
<Setting name="SomeProjectClientRepository" />
<Setting name="SomeProjectMessagesInProcess" />
</ConfigurationSettings>
<LocalResources>
<LocalStorage name="InstallLogs" sizeInMB="5" cleanOnRoleRecycle="false" />
</LocalResources>
<Startup>
<Task commandLine="install.cmd" executionContext="elevated" taskType="simple">
<Environment>
<Variable name="PathToInstallLogs">
<RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/LocalResources/LocalResource[#name='InstallLogs']/#path" />
</Variable>
</Environment>
</Task>
</Startup>
</WorkerRole>
<WorkerRole name="SomeProject.Engine" vmsize="Small">
<Contents>
<Content destination="ClientCustomCode">
<SourceDirectory path="ClientCustomCode" />
</Content>
</Contents>
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" />
<Setting name="RequestQueue" />
<Setting name="RequestErrorQueue" />
<Setting name="SomeProjectDocumentDBURI" />
<Setting name="SomeProjectAuthorizationKey" />
<Setting name="LogLevel" />
<Setting name="NumberOfConcurrentRequests" />
<Setting name="NumberOfRequestsToReadFromAzureQueue" />
<Setting name="StorageConnectionString" />
<Setting name="SomeProjectPnrHistory" />
<Setting name="SomeProjectClientRepository" />
<Setting name="SomeProjectMessagesInProcess" />
</ConfigurationSettings>
<LocalResources>
<LocalStorage name="InstallLogs" sizeInMB="5" cleanOnRoleRecycle="false" />
</LocalResources>
<Startup>
<Task commandLine="install.cmd" executionContext="elevated" taskType="simple">
<Environment>
<Variable name="PathToInstallLogs">
<RoleInstanceValue xpath="/RoleEnvironment/CurrentInstance/LocalResources/LocalResource[#name='InstallLogs']/#path" />
</Variable>
</Environment>
</Task>
</Startup>
</WorkerRole>
In the cloud project I added the following in the build events:
-- Pre-build
IF NOT EXIST $(TargetDir)ClientCustSomCode mkdir $(TargetDir)ClientCustomCode
-- Post-build
IF NOT EXIST $(TargetDir)ClientCustomCode mkdir $(TargetDir)ClientCustomCode
copy $(ProjectDir)ClientCustomCode\*.dll $(TargetDir)ClientCustomCode
copy $(ProjectDir)ClientCustomCode\*.pdb $(TargetDir)ClientCustomCode
In the project file where the copied dll is actually build:
copy $(TargetName).dll $(SolutionDir)SomeProject\SomeProject.Cloud\ClientCustomCode
copy $(TargetName).pdb $(SolutionDir)SomeProject\SomeProject.Cloud\ClientCustomCode
Now, locally this builds with no problem. Until recently it also build on Team Services, but out of the blue, without any real reason (nothing was changed) the build suddenly started to fail with the following error:
2016-08-23T08:37:40.3013767Z C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\ServiceDefinition.csdef : error CloudServices089: Cannot find the source directory 'C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\ClientCustomCode' in role SomeProject.Foreman. [C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\SomeProject.Cloud.ccproj]
2016-08-23T08:37:40.3013767Z C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\ServiceDefinition.csdef : error CloudServices089: Cannot find the source directory 'C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\ClientCustomCode' in role SomeProject.Engine. [C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\SomeProject.Cloud.ccproj]
Build log file: Download
Does anyone here might have an idea?
error CloudServices089: Cannot find the source directory 'C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\ClientCustomCode' in role SomeProject.Foreman. [C:\a\1\s\SomeStuff\SomeProject\SomeProject.Cloud\SomeProject.Cloud.ccproj]
The install.cmd is used to create directory and copy assemblies to the new directory. From the error message, I think the install.cmd is not executed. Maybe the install.cmd does not deploy to worker role. Please verify via enable Remote desktop when publish the application:
We could find the install.cmd in the directory E:\approot in worker role instance.
Please try to find install.cmd in your solution, then set the Copy to Output Directory as Copy always to see whether it works, like following:
I just upgraded (via nuget) to the latest version of the Azure Configuration Manager (3.0.0):
https://www.nuget.org/packages/Microsoft.WindowsAzure.ConfigurationManager/3.0.0
Once I did that - and made a few namespace adjustments - it looks like it has stopped returning values for my Azure Worker Role configuration.
I'm retrieving a connection string value like this:
var storageCs = CloudConfigurationManager.GetSetting("Microsoft.Storage.ConnectionString");
My service definition file looks like this:
<?xml version="1.0"?>
<ServiceDefinition name="Payboard.Worker" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition" schemaVersion="2014-06.2.4">
<WorkerRole name="Payboard.Worker.Events" vmsize="Small">
<ConfigurationSettings>
<Setting name="Microsoft.Storage.ConnectionString" />
<Setting name="PayboardEntities" />
<Setting name="cacheSystem" />
<Setting name="Microsoft.WindowsAzure.Plugins.Caching.ClientDiagnosticLevel" />
<Setting name="redisCacheConnectionString" />
</ConfigurationSettings>
<Imports>
<Import moduleName="RemoteAccess" />
<Import moduleName="RemoteForwarder" />
</Imports>
<Startup priority="-2">
</Startup>
</WorkerRole>
</ServiceDefinition>
And my service configuration file like so (with sensitive information removed):
<?xml version="1.0"?>
<ServiceConfiguration serviceName="Payboard.Worker" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="4" osVersion="*" schemaVersion="2014-06.2.4">
<Role name="Payboard.Worker.Events">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.Storage.ConnectionString" value="UseDevelopmentStorage=true" />
<Setting name="PayboardEntities" value="(standard connection string stuff)" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="true" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="ken" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="(encrypted password)" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="2015-06-19T23:59:59.0000000-07:00" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="true" />
<Setting name="cacheSystem" value="simple" />
<Setting name="Microsoft.WindowsAzure.Plugins.Caching.ClientDiagnosticLevel" value="1" />
<Setting name="redisCacheConnectionString" value="(redis connection string)" />
</ConfigurationSettings>
<Certificates>
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="(blah)" thumbprintAlgorithm="sha1" />
</Certificates>
</Role>
</ServiceConfiguration>
All of this worked correctly under 2.0.3, and indeed, works correctly if I revert back to 2.0.3. But any call to CloudConfigurationManager.GetSetting() returns null under 3.0.
I haven't found any documentation about what's supposedly changed under 3.0. Anybody have any suggestions? Is this just a bug of some sort? (Obviously I'm sticking at 2.x for now - no compelling reason to get to 3.0 - but I like sticking with the latest versions of stuff as a general rule.)
This is fixed in the newly published version 3.1.0.
Cheers,
Ogail
This is because a class called AzureApplicationSettings that loads the ServiceRuntime is looking for an assembly called Microsoft.Azure.ServiceRuntime (see below). The current version in the 2.5 sdk still has the old name (Microsoft.WindowsAzure). This assembly (at least, in the past) has not been provided through nuget but instead ships with the SDK. There is a big Azure announcement next week (3/24/15) so possibly we'll get a new SDK at that time. The various Azure groups have so far been working out the kinks of exactly how to push time coordinated releases that are interdependent on each other.
private readonly string[] knownAssemblyNames = new string[]
{
"Microsoft.Azure.ServiceRuntime, Culture=neutral, PublicKeyToken=31bf3856ad364e35, ProcessorArchitecture=MSIL"
}
I have an Azure cloud service app that is comprised of a worker role (1 instance only) and a web role (multiple instances). The web role is also where the Microsoft.WindowsAzure.Caching's (version 2.2) in-role co-located cache cluster resides. I have Azure diagnostics set up and in my WadLogsTable I see this pair of warnings every few minutes in production:
WARNING: DeadServerCallback Called, Server URI: [net.tcp://100.74.158.31:20005], Underlying exception - ; TraceSource 'w3wp.exe' event
WARNING: DeadServerCallback: Matches My Server, Cleaning Pending Requests; TraceSource 'w3wp.exe' event
The net.tcp://100.74.158.31:20005 corresponds to one of the web roles. The warnings sporatically alternate between the web roles (i.e. sometimes it says net.tcp://100.74.158.51:20005).
Notice that there is nothing after "Underlying exception - ". There are also no related exceptions in the WadWindowsEventLogsTable (I know that Azure exception logging is working because I will occasionally see other exceptions in that table). I believe I've also turned on all the Caching diagnostics that I could.
So my issue is that I am seeing all these warnings but I don't know why and I don't know how to remedy the situation. It doesn't appear that these warnings are causing the app to crash, but still they are worrisome. Any help would be appreciated.
Here is my ServiceConfiguration.cscfg:
<?xml version="1.0"?>
<ServiceConfiguration serviceName="CloudService" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="3" osVersion="*" schemaVersion="2013-10.2.2">
<Role name="WebRole">
<Instances count="2" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=XXXXX;AccountKey=XXXXX" />
<Setting name="Microsoft.WindowsAzure.Plugins.Caching.NamedCaches" value="{"caches":[{"name":"default","policy":{"eviction":{"type":0},"expiration":{"defaultTTL":10,"isExpirable":true,"type":2},"serverNotification":{"isEnabled":false}},"secondaries":0}]}" />
<Setting name="Microsoft.WindowsAzure.Plugins.Caching.DiagnosticLevel" value="3" />
<Setting name="Microsoft.WindowsAzure.Plugins.Caching.CacheSizePercentage" value="30" />
<Setting name="Microsoft.WindowsAzure.Plugins.Caching.ConfigStoreConnectionString" value="DefaultEndpointsProtocol=https;AccountName=XXXXX;AccountKey=XXXXX" />
<Setting name="Microsoft.WindowsAzure.Plugins.Caching.ClientDiagnosticLevel" value="3" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="true" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="Me" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="XXXXX" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="2014-08-05T23:59:59.0000000-07:00" />
</ConfigurationSettings>
<Certificates>
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="XXXXX" thumbprintAlgorithm="sha1" />
<Certificate name="www.myapp.com" thumbprint="XXXXX" thumbprintAlgorithm="sha1" />
</Certificates>
</Role>
<Role name="WorkerRole">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="Microsoft.WindowsAzure.Plugins.Caching.ClientDiagnosticLevel" value="3" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.Enabled" value="true" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountUsername" value="Me" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountEncryptedPassword" value="XXXXX" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteAccess.AccountExpiration" value="2014-08-05T23:59:59.0000000-07:00" />
<Setting name="Microsoft.WindowsAzure.Plugins.RemoteForwarder.Enabled" value="true" />
<!-- For Windows Azure ServiceManagement. -->
<Setting name="SubscriptionId" value="XXXXX" />
<Setting name="ServiceManagementCertificateThumbprint" value="value="XXXXX" " />
<Setting name="Microsoft.WindowsAzure.Plugins.Diagnostics.ConnectionString" value="DefaultEndpointsProtocol=https;AccountName=XXXXX;AccountKey=XXXXX" />
</ConfigurationSettings>
<Certificates>
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="XXXXX" thumbprintAlgorithm="sha1" />
<!-- For Windows Azure ServiceManagement. -->
<Certificate name="ServiceManagementCertificate" thumbprint="thumbprint="XXXXX" " thumbprintAlgorithm="sha1" />
</Certificates>
</Role>
</ServiceConfiguration>
Here are pertinent parts of the Web.config of my web role:
<dataCacheClients>
<dataCacheClient name="default" connectionPool="true" useLegacyProtocol="false" isCompressionEnabled="false" maxConnectionsToServer="2">
<autoDiscover isEnabled="true" identifier="WebRole" />
</dataCacheClient>
</dataCacheClients>
<cacheDiagnostics>
<crashDump dumpLevel="Full" dumpStorageQuotaInMB="100" scheduledTransferPeriodInMinutes="5" />
</cacheDiagnostics>
Here are pertinent parts of the App.config of my worker role:
<dataCacheClients>
<dataCacheClient name="default" connectionPool="true" useLegacyProtocol="false" isCompressionEnabled="false" maxConnectionsToServer="2">
<autoDiscover isEnabled="true" identifier="WebRole" />
</dataCacheClient>
</dataCacheClients>
<cacheDiagnostics>
<crashDump dumpLevel="Full" dumpStorageQuotaInMB="100" scheduledTransferPeriodInMinutes="5" />
</cacheDiagnostics>
Additional notes:
I've probably tried every possible combination of attribute settings for both the <dataCacheClient> entries in the web role's
Web.config and worker role's App.config.
The cloud service has been upgraded to use Windows Azure Tools version 2.2.
I've Googled and found a few posts related to these warnings but it seems that most people only experienced this in the compute emulator, not on production like I am. Nevertheless, I've tried most of their suggested solutions and nothing has helped.
As long as you dont see any failures or timeouts or drop in quality of the service, you should be good. The deadserver callback should be just cleaning up old unused connections. To validate this hypothesis :
Do you have any other connection errors happening in verbose logging ? Can you see if the last request to this server was a long time back ? Do you have bursty traffic ?
Can we read certificate section withi ServiceConfiguration.cscfg file using c#? There is method inside RoleEnvironment class to read ConfigurationSettings, but not certificate section.
<?xml version="1.0" encoding="utf-8"?>
<ServiceConfiguration serviceName="WindowsAzureProject7" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration" osFamily="1" osVersion="*">
<Role name="MvcWebRole1" >
<Instances count="1" />
<Certificates>
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="625FBBB3B7A25C4B9D1C49D1CB1E3AE196C1A083" thumbprintAlgorithm="sha1" />
</Certificates>
</Role>
</ServiceConfiguration>
Yes, there is no API to read certificate details as far as i know, however what you can do is create a configuration setting and add your certificate specific details and read it directly from the same API. Here is the trick, I used in past:
<ServiceConfiguration serviceName="RW" xmlns="http://schemas.microsoft.com/ServiceHosting/2008/10/ServiceConfiguration">
<Role name="RR">
<Instances count="1" />
<ConfigurationSettings>
<Setting name="AppFolder" value="RailsApp" />
<Setting name="CertificateThumb" value="*************" />
</ConfigurationSettings>
<Certificates>
<Certificate name="Microsoft.WindowsAzure.Plugins.RemoteAccess.PasswordEncryption" thumbprint="*****************************" thumbprintAlgorithm="sha1" />
</Certificates>
</Role>
</ServiceConfiguration>
Now, in my role specific code, I can call RoleEnvironment.GetConfigurationSettingValue to get the certificate thumb as below:
string certThumb = RoleEnvironment.GetConfigurationSettingValue("CertificateThumb");
Hey Everyone,
How do I fix the Compiler Error upon compiling on "return ((string)(this["TargetDir"]));":
System.Configuration.ConfigurationErrorsException was unhandled
Configuration system failed to initialize
{"Unrecognized configuration section userSettings/CCP.Settings1. (C:\\Users\\bmccarthy\\Documents\\Visual Studio 2008\\Projects\\CCP Utility\\CCP Utility\\bin\\Debug\\CCP_Utility.exe.config line 21)"}
A first chance exception of type 'System.Configuration.ConfigurationErrorsException' occurred in System.Configuration.dll
Here's the code in my Settings.Designer.cs file under the Properties directory:
[global::System.Configuration.UserScopedSettingAttribute()]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Configuration.DefaultSettingValueAttribute("")]
public string TargetDir {
get {
return ((string)(this["TargetDir"]));
}
set {
this["TargetDir"] = value;
}
}
Here's the code for CCP_Utility.exe.config from the bin folder:
<CCP_Utility.Properties.Settings>
<setting name="SourceDir" serializeAs="String">
<value />
</setting>
<setting name="TargetDir" serializeAs="String">
<value />
</setting>
<setting name="CorpID" serializeAs="String">
<value />
</setting>
</CCP_Utility.Properties.Settings>
<CCP_Utility.Settings1>
<setting name="sourceDir" serializeAs="String">
<value />
</setting>
<setting name="targetDir" serializeAs="String">
<value />
</setting>
</CCP_Utility.Settings1>
What does the < CCP_Utility.Settings1 > tag have to match up to?? App.config and what else?
Does capitalization matter? I have the variable declared as TargetDir Settings.Settings....
Where is the System.Configuration.dll file located?
I got the application to compile without compiler errors by changing the capitilzation of sourceDir and targetDir under CCP_Utility.Settings1 in the Settings1.Designer.cs file as follows:
<CCP_Utility.Settings1>
<setting name="SourceDir" serializeAs="String">
<value />
</setting>
<setting name="TargetDir" serializeAs="String">
<value />
</setting>
</CCP_Utility.Settings1>
Verify UserScopedSettingAttribute matches up with the correct settings section.
If I remember correct, yes, case-sensitive.
Usually, I will add a setting, save and close, then open the settings designer again, and delete the setting, save and close. This will get the designer in-sync. I have seen them get out-of-sync the first time the designer is opened on a computer. (For example, when you get from source control.)