public void CloudFileShareCreateIfNotExists() { CloudFileShare share = GetRandomShareReference(); try { Assert.IsTrue(share.CreateIfNotExists()); Assert.IsFalse(share.CreateIfNotExists()); } finally { share.DeleteIfExists(); } }
public AzureOperations(string connectionString, string shareName) { var account = CloudStorageAccount.Parse(connectionString); client = account.CreateCloudFileClient(); share = client.GetShareReference(shareName); share.CreateIfNotExists(); root = share.GetRootDirectoryReference(); }
public FileStorage(string fileShareName, string storageConnectionString ) { Validate.String(fileShareName, "fileShareName"); Validate.String(storageConnectionString, "storageConnectionString"); var cloudStorageAccount = CloudStorageAccount.Parse(storageConnectionString); var fileClient = cloudStorageAccount.CreateCloudFileClient(); cloudFileShare = fileClient.GetShareReference(fileShareName); cloudFileShare.CreateIfNotExists(); }
private void Initialise(LoggingEvent loggingEvent) { if (_storageAccount == null || AzureStorageConnectionString != _thisConnectionString) { _storageAccount = CloudStorageAccount.Parse(AzureStorageConnectionString); _thisConnectionString = AzureStorageConnectionString; _client = null; _share = null; _folder = null; _file = null; } if (_client == null) { _client = _storageAccount.CreateCloudFileClient(); _share = null; _folder = null; _file = null; } if (_share == null || _share.Name != ShareName) { _share = _client.GetShareReference(ShareName); _share.CreateIfNotExists(); _folder = null; _file = null; } if (_folder == null || Path != _thisFolder) { var pathElements = Path.Split(new[] {'\\', '/'}, StringSplitOptions.RemoveEmptyEntries); _folder = _share.GetRootDirectoryReference(); foreach (var element in pathElements) { _folder = _folder.GetDirectoryReference(element); _folder.CreateIfNotExists(); } _thisFolder = Path; _file = null; } var filename = Regex.Replace(File, @"\{(.+?)\}", _ => loggingEvent.TimeStamp.ToString(_.Result("$1"))); if (_file == null || filename != _thisFile) { _file = _folder.GetFileReference(filename); if (!_file.Exists()) _file.Create(0); _thisFile = filename; } }