Quantcast
Channel: Azure Management Portal forum
Viewing all articles
Browse latest Browse all 4189

How to use Encrypted Diagnostics ConnectionString for Azure logging

$
0
0
Hi,
I want to use Encryted Diagnostics ConnectionString   for logging purpose because due to some policy.
Please find my implementation for the same .
 
 

publicoverridebool OnStart(){

DiagnosticMonitorConfiguration config = DiagnosticMonitor.GetDefaultInitialConfiguration();

double logTransferInterval =Convert.ToDouble(RoleEnvironment.GetConfigurationSettingValue("LogTransferInterval"));

// Set scheduled transfer interval for infrastructure logs to 1 minute

config.DiagnosticInfrastructureLogs.ScheduledTransferPeriod = System.

TimeSpan.FromMinutes(logTransferInterval);

// Set scheduled transfer interval for user's Windows Azure Logs to 1 minute

config.WindowsEventLog.DataSources.Add(

"System!*");

config.WindowsEventLog.DataSources.Add(

"Application!*");

config.Logs.ScheduledTransferPeriod = System.

TimeSpan.FromMinutes(1);

//Decrypt the Storage AccountName and Key

string decryptAccountName = EncryptDecrypt.DecryptMsg(RoleEnvironment.GetConfigurationSettingValue("AccountName"));

string decryptAccountKey = EncryptDecrypt.DecryptMsg(RoleEnvironment.GetConfigurationSettingValue("AccountKey"));

StorageCredentialsAccountAndKey accountAndKey =

new StorageCredentialsAccountAndKey(decryptAccountName, decryptAccountKey);

CloudStorageAccount storageAccount =

new CloudStorageAccount(accountAndKey,true);

DiagnosticMonitor.Start(storageAccount, config);

CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSettingPublisher) =>

{

var connectionString = RoleEnvironment.GetConfigurationSettingValue(configName);

configSettingPublisher(connectionString);

}

);

// For information on handling configuration changes

RoleEnvironment.Changing += RoleEnvironmentChanging;

returnbase.OnStart();

}

In above code i have configured Encrypted storage account and storage key and now i am descripting  the connection string and plug-in for logging .

But whenever I am trying to log something then it’s not logging

Your Help will be appreciated very much.


cpsingh

Viewing all articles
Browse latest Browse all 4189

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>