我已经在我的应用程序中添加了azure项目,并在.cscfg文件下的名为“ MasterDBConnection”的设置标签中添加了数据库连接字符串值,如下所示:
<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>
现在,当我从.cscfg文件调用连接字符串值时,它显示错误。 我在调用连接字符串,如下所示:
string connMaster = RoleEnvironment.GetConfigurationSettingValue("MasterDBConnection");
错误显示如下:
An exception of type 'Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironmentException' occurred in Microsoft.WindowsAzure.ServiceRuntime.dll but was not handled in user code
Additional information: error