예제 #1
0
        /// <summary>
        /// Creates a file share utility wrapper for azure infrastructure.
        /// </summary>
        /// <param name="cloudStorageConnectionString">The connection string for azure (valid format needed), e.g. DefaultEndpointsProtocol=https;AccountName=bmwrcvdev;AccountKey=APUfaYGYAOk7owSH2P2Uy/2BWDYxFLJsKgGcG0DyhdYdWS6TRfdEYmKvlk7VewwdaorfetwB2MSfLckQm7a9YA==;EndpointSuffix=core.windows.net</param>
        /// <param name="shareName">The name of configured azure file share.</param>
        public AzureFileContainer(string cloudStorageConnectionString, string shareName)
        {
            #region validation

            if (string.IsNullOrEmpty(cloudStorageConnectionString))
            {
                throw new ArgumentNullException(nameof(cloudStorageConnectionString));
            }

            if (string.IsNullOrEmpty(shareName))
            {
                throw new ArgumentNullException(nameof(shareName));
            }

            #endregion

            CloudStorageAccount = CloudStorageAccount.Parse(cloudStorageConnectionString);

            CloudFileShare = CloudStorageAccount.GetShareReference(shareName);
        }
예제 #2
0
        public void Initialize()
        {
            _fileContainer = new AzureFileContainer(CONNECTION_STRING, SHARE_NAME);

            _cloudStorageAccount = CloudStorageAccount.Parse(CONNECTION_STRING);

            _cloudFileShare = _cloudStorageAccount.GetShareReference(SHARE_NAME);

            _cloudFileRootDirectory = _cloudFileShare.GetRootDirectoryReference();

            _cloudFileSourceDirectory = _cloudFileShare.GetDirectoryReference(path: new[] { SOURCE_DIRECTORY }, createIfNotExists: true);

            _cloudFileShare.GetDirectoryReference(path: new[] { SOURCE_DIRECTORY, DUMMY_DIRECTORY }, createIfNotExists: true);

            _cloudFileShare.GetDirectoryReference(path: new[] { TARGET_DIRECTORY }, createIfNotExists: true);

            _cloudRootFile = _cloudFileRootDirectory.GetFileReference(FILE_NAME);

            _cloudSourceFile = _cloudFileSourceDirectory.GetFileReference(FILE_NAME);

            TaskUtilities.ExecuteSync(_cloudRootFile.UploadTextAsync(FILE_CONTENT));

            TaskUtilities.ExecuteSync(_cloudSourceFile.UploadTextAsync(FILE_CONTENT));
        }