Пример #1
0
 /// <summary>
 /// Opens a container or Creates if one with the given name does not exist.
 /// </summary>
 /// <param name="containerName">The name of the container to open. If the container with the given name does not exist, it will be creted.</param>
 /// <param name="accessControl">Could be public or private.</param>
 /// <returns>Success/Failure whether open/create succeeded or not.</returns>
 public override bool OpenOrCreate(string containerName, string accessControl)
 {
     bool result = true;
     blobContainer = blobStorage.GetBlobContainer(containerName);
     if (!blobContainer.DoesContainerExist())
     {
         result = blobContainer.CreateContainer();
     }
     blobContainer.SetContainerAccessControl((ContainerAccessControl)Enum.Parse(typeof(ContainerAccessControl), accessControl, true));
     return result;
 }
Пример #2
0
 private BlobContainer GetContainer()
 {
     // we have to make sure that only one thread tries to create the container
     lock (_lock)
     {
         if (_container != null)
         {
             return _container;
         }
         try
         {
             BlobContainer container = BlobStorage.Create(_info).GetBlobContainer(_containerName);
             container.Timeout = _Timeout;
             container.RetryPolicy = _RetryPolicy;
             container.CreateContainer();
             _container = container;
             return _container;
         }
         catch (StorageException se)
         {
             Log.Write(EventKind.Error, "Error creating container {0}: {1}", ContainerUrl, se.Message);
             throw;
         }
     }
 }