public void Set_the_maximum_size_for_a_file_share() { // Parse the connection string for the storage account. StorageCredentials Credentials = new StorageCredentials(this.Account, this.Key); CloudStorageAccount storageAccount = new CloudStorageAccount(Credentials, false); // Create a CloudFileClient object for credentialed access to File storage. CloudFileClient fileClient = storageAccount.CreateCloudFileClient(); // Get a reference to the file share we created previously. CloudFileShare share = fileClient.GetShareReference("logs"); // Ensure that the share exists. if (share.Exists()) { // Check current usage stats for the share. // Note that the ShareStats object is part of the protocol layer for the File service. Microsoft.WindowsAzure.Storage.File.Protocol.ShareStats stats = share.GetStats(); Console.WriteLine("Current share usage: {0} GB", stats.Usage.ToString()); // Specify the maximum size of the share, in GB. // This line sets the quota to be 10 GB greater than the current usage of the share. share.Properties.Quota = 10 + stats.Usage; share.SetProperties(); // Now check the quota for the share. Call FetchAttributes() to populate the share's properties. share.FetchAttributes(); Console.WriteLine("Current share quota: {0} GB", share.Properties.Quota); } }
static void CreateShareFile() { try { #region Creating the Shared Files in Azure _storageAccount = CloudStorageAccount.Parse( CloudConfigurationManager.GetSetting("StorageConnection")); _share = _storageAccount.CreateCloudFileClient().GetShareReference("documentos"); if (_share.Exists()) { //Console.Clear(); // Check current usage stats for the share. // Note that the ShareStats object is part of the protocol layer for the File service. ShareStats stats = _share.GetStats(); //Console.WriteLine("Current share usage: {0} GB", stats.Usage.ToString()); // Specify the maximum size of the share, in GB. // This line sets the quota to be 10 GB greater than the current usage of the share. _share.Properties.Quota = 10 + stats.Usage; _share.SetProperties(); // Now check the quota for the share. Call FetchAttributes() to populate the share's properties. _share.FetchAttributes(); //Console.WriteLine("Current share quota: {0} GB", _share.Properties.Quota); // Create a new shared access policy and define its constraints. SharedAccessFilePolicy sharedPolicy = new SharedAccessFilePolicy() { SharedAccessExpiryTime = DateTime.UtcNow.AddHours(24), Permissions = SharedAccessFilePermissions.Read | SharedAccessFilePermissions.Write }; // Get existing permissions for the share. FileSharePermissions permissions = _share.GetPermissions(); if (!permissions.SharedAccessPolicies.ContainsKey("sampleSharePolicy")) { // Add the shared access policy to the share's policies. Note that each policy must have a unique name. permissions.SharedAccessPolicies.Add("sampleSharePolicy", sharedPolicy); _share.SetPermissions(permissions); } //Console.ReadKey(); } else { _share.CreateIfNotExists(); } #endregion } catch (Exception ex) { Console.WriteLine(ex); Console.ReadKey(); } }
public void SetShareProperties(CloudFileShare share, AccessCondition accessCondition, FileRequestOptions options, OperationContext operationContext) { share.SetProperties(accessCondition, options, operationContext); }