// <snippet_UploadFileWithSas> // <snippet_SetMaxShareSize> //------------------------------------------------- // Set the maximum size of a share //------------------------------------------------- public async Task SetMaxShareSizeAsync(string shareName, int increaseSizeInGiB) { const long ONE_GIBIBYTE = 10737420000; // Number of bytes in 1 gibibyte // Get the connection string from app settings string connectionString = ConfigurationManager.AppSettings["StorageConnectionString"]; // Instantiate a ShareClient which will be used to access the file share ShareClient share = new ShareClient(connectionString, shareName); // Create the share if it doesn't already exist await share.CreateIfNotExistsAsync(); // Ensure that the share exists if (await share.ExistsAsync()) { // Get and display current share quota ShareProperties properties = await share.GetPropertiesAsync(); Console.WriteLine($"Current share quota: {properties.QuotaInGB} GiB"); // Get and display current usage stats for the share ShareStatistics stats = await share.GetStatisticsAsync(); Console.WriteLine($"Current share usage: {stats.ShareUsageInBytes} bytes"); // Convert current usage from bytes into GiB int currentGiB = (int)(stats.ShareUsageInBytes / ONE_GIBIBYTE); // This line sets the quota to be the current // usage of the share plus the increase amount await share.SetQuotaAsync(currentGiB + increaseSizeInGiB); // Get the new quota and display it properties = await share.GetPropertiesAsync(); Console.WriteLine($"New share quota: {properties.QuotaInGB} GiB"); } }