Exemple #1
0
        /// <summary>
        /// Uploads a file as a blob to a container in Azure storage. If the container does not
        /// exist then it will be created. If a file with the same name exists it will be overwritten.
        /// </summary>
        /// <param name="containerName">The name of the storage container.</param>
        /// <param name="fileName">The name of the file to upload.</param>
        /// <param name="content">The content of the file to upload as a string.</param>
        /// <returns>The URL to the uploaded file with a SaS key.</returns>
        private async Task <string> uploadToBlobStorageAsync(string containerName, string fileName, string content)
        {
            if (await _storageUtility.ContainerExistsAsync(containerName) is false)
            {
                // Container does not exist so create one
                await _storageUtility.CreateContainerAsync(containerName);
            }

            // TODO: get random name
            var url = await _storageUtility.UploadTextFileAsync(containerName, fileName, content, true);

            return(url);
        }