public override void Run() { // This is a sample worker implementation. Replace with your logic. Trace.WriteLine("WorkerRole1 entry point called", "Information"); CloudStorageAccount.SetConfigurationSettingPublisher( (name, publisher) => { var connectionString = RoleEnvironment.GetConfigurationSettingValue(name); publisher(connectionString); } ); var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); AzureQueue <UserRegistrationMessage> queue = new AzureQueue <UserRegistrationMessage>(account); queue.EnsureExist(); AzureBlobContainer <RegistrationTokenEntity> registrationBlob = new AzureBlobContainer <RegistrationTokenEntity>(account, "registrationtoken", true); registrationBlob.EnsureExist(true); while (true) { try { var message = queue.GetMessage(); if (message != null) { var entity = new RegistrationTokenEntity(); entity.RegistrationToken = (new Random()).Next().ToString(); registrationBlob.Save(message.RegistratoinId, entity); queue.DeleteMessage(message); } } catch { } Thread.Sleep(5000); } }
public ActionResult Register(RegisterModel model) { AzureQueue<UserRegistrationMessage> queue = new AzureQueue<UserRegistrationMessage>(account); AzureBlobContainer<RegistrationTokenEntity> registrationBlob = new AzureBlobContainer<RegistrationTokenEntity>(account, true); var containerId = Guid.NewGuid().ToString(); registrationBlob.Save(containerId, new RegistrationTokenEntity { RegistrationToken = null, }); var blobContainer = registrationBlob.GetSharedAccessSignature(containerId, DateTime.Now.AddHours(1)); queue.AddMessage(new UserRegistrationMessage { DateOfBirth = model.DateOfBirth, Email = model.Email, FirstName = model.FirstName, LastName = model.LastName, ContainerId = containerId, }); return Json(new { container = blobContainer }); }
public override void Run() { // This is a sample worker implementation. Replace with your logic. Trace.WriteLine("WorkerRole1 entry point called", "Information"); CloudStorageAccount.SetConfigurationSettingPublisher( (name, publisher) => { var connectionString = RoleEnvironment.GetConfigurationSettingValue(name); publisher(connectionString); } ); var account = CloudStorageAccount.FromConfigurationSetting("DataConnectionString"); AzureQueue<UserRegistrationMessage> queue = new AzureQueue<UserRegistrationMessage>(account); queue.EnsureExist(); AzureBlobContainer<RegistrationTokenEntity> registrationBlob = new AzureBlobContainer<RegistrationTokenEntity>(account, "registrationtoken", true); registrationBlob.EnsureExist(true); while (true) { try { var message = queue.GetMessage(); if (message != null) { var entity = new RegistrationTokenEntity(); entity.RegistrationToken = (new Random()).Next().ToString(); registrationBlob.Save(message.RegistratoinId, entity); queue.DeleteMessage(message); } } catch { } Thread.Sleep(5000); } }