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); } }
/// <summary> /// Reads share stats from a stream. /// </summary> /// <param name="inputStream">The stream from which to read the share stats.</param> /// <returns>The share stats stored in the stream.</returns> public static ShareStats ReadShareStats(Stream inputStream) { using (XmlReader reader = XmlReader.Create(inputStream)) { XDocument shareStatsDocument = XDocument.Load(reader); return(ShareStats.FromServiceXml(shareStatsDocument)); } }
/// <summary> /// Reads share stats from a stream. /// </summary> /// <param name="inputStream">The stream from which to read the share stats.</param> /// <returns>The share stats stored in the stream.</returns> public static Task <ShareStats> ReadShareStatsAsync(Stream inputStream, CancellationToken token) { return(Task.Run( () => { using (XmlReader reader = XmlReader.Create(inputStream)) { XDocument shareStatsDocument = XDocument.Load(reader); return ShareStats.FromServiceXml(shareStatsDocument); } }, token )); }