none
Host storage for my clients. What do you think?

    Question

  • Hi

    I want to create a backup site for my clients. It will work like that: each client will install a client-side software (which I will develope), and the user will be able to choose files and directories to backup.
    the data will be uploaded to my azure storage account.
    my question is: should i have multiple azure accounts for each user or should I use my account and create seperate blobs? If so, should I use seperate connection string to each client?

    Monday, November 28, 2016 9:09 AM

All replies

  • I believe you can have a single Blob with separate containers for your clients, so there is no need for multiple connection strings. You can only hold container names on client side.

    Not sure if it's going to help but on client side your RoleEntryPoint might will be like.

        public class AzureStorageRepository : RoleEntryPoint
        {        
            internal CloudStorageAccount storageAccount;
    
            public AzureStorageRepository()
            {
                // Retrieve the storage account from the connection string.
                storageAccount = CloudStorageAccount.Parse(CloudConfigurationManager.GetSetting("AzureStorageConnectionString"));
            }
    
            public override bool OnStart()
            {
    
                return base.OnStart();
            }
    
    
        }

    and you can inherit your client class from it and use like

        public class BlobRepository : AzureStorageRepository
        {
            CloudBlobClient blobClient;
            CloudBlobContainer blobContainer;
    
            public BlobRepository()
            {
                blobClient = storageAccount.CreateCloudBlobClient();
            }
    
            /// <summary>
            /// Uploads the given stream to the name of the blob. Please note that if blob exists, contents will be overriten.
            /// </summary>
            /// <param name="fileStream"></param>
            /// <param name="blobNameToCreate"></param>
            /// <param name="containerName"></param>
            /// <returns></returns>
            public async Task UploadBlobAsync(Stream fileStream, string blobName, string containerName)
            {
                // Retrieve reference the given container
                CloudBlobContainer container = blobClient.GetContainerReference(containerName);
    
                // Retrieve reference to the blob
                CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName);
    
                // Create or overwrite blob with contents from parameter.
                await blockBlob.UploadFromStreamAsync(fileStream);
            }

    Monday, November 28, 2016 1:21 PM
  • Hi kasper777,

     

    You could create container for each user for storing backup data (in this way, you will need to manage multiple containers). Or you could name blobs with path information in their names, which will create a virtual directory structure that you can organize and traverse as you would a traditional file system, users could upload backup data to their own folder in a container.

    CloudBlockBlob blockBlob = blobcontainer.GetBlockBlobReference("Userbackupdata/username/actualdataorfile");

    • Edited by Fred Han Tuesday, November 29, 2016 5:46 AM
    Tuesday, November 29, 2016 5:46 AM