static void Main(string[] args) { try { _realm = new AwsRealm(); _queueProvider = _realm.QueueProvider; const string queueId = "cloudmorph-testqueue"; try { var queue = _queueProvider.GetQueueById(queueId); Console.WriteLine("Queue exists."); return; } catch { } bool bResult = _queueProvider.CreateQueue(queueId); if (bResult) Console.WriteLine("The queue {0} was successfully created", queueId); } catch (Exception e) { Console.WriteLine(e); } }
public override bool OnStart() { // Set the maximum number of concurrent connections ServicePointManager.DefaultConnectionLimit = 12; // read storage account configuration settings CloudStorageAccount.SetConfigurationSettingPublisher((configName, configSetter) => { configSetter(RoleEnvironment.GetConfigurationSettingValue(configName)); }); var _azure = new AzureRealm(); // initialize blob storage _storage = _azure.StorageProvider; _storage.CreateBucket("guestbookpics1"); // initialize queue storage _queueProvider = _azure.QueueProvider; _queueProvider.CreateQueue("guestthumbs"); _queue = _queueProvider.GetQueueById("guestthumbs"); Trace.TraceInformation("Creating container and queue..."); return base.OnStart(); }
private void InitializeStorage() { if (storageInitialized) { return; } lock (gate) { if (storageInitialized) { return; } try { // create blob container for images var _azure = new AzureRealm(); _storage = _azure.StorageProvider; _storage.CreateBucket("guestbookpics1"); //_storage.CreateIfNotExist(); // configure container for public access //var permissions = container.GetPermissions(); //permissions.PublicAccess = BlobContainerPublicAccessType.Container; //container.SetPermissions(permissions); // create queue to communicate with worker role _queue = _azure.QueueProvider; _queue.CreateQueue("guestthumbs"); //queue.CreateIfNotExist(); } catch (WebException) { throw new WebException("Storage services initialization failure. " + "Check your storage account configuration settings. If running locally, " + "ensure that the Development Storage service is running."); } storageInitialized = true; } }