public async Task UpdateFileShare() { //create file share string fileShareName = Recording.GenerateAssetName("testfileshare"); FileShare share1 = (await _fileShareCollection.CreateOrUpdateAsync(true, fileShareName, new FileShareData())).Value; Assert.AreEqual(share1.Id.Name, fileShareName); //update metadata and share quota FileShareData shareData = share1.Data; shareData.Metadata.Add("key1", "value1"); shareData.Metadata.Add("key2", "value2"); shareData.ShareQuota = 5000; FileShare share2 = await share1.UpdateAsync(shareData); //validate Assert.NotNull(share2.Data.Metadata); Assert.AreEqual(share2.Data.ShareQuota, shareData.ShareQuota); Assert.AreEqual(share2.Data.Metadata, shareData.Metadata); FileShare share3 = await _fileShareCollection.GetAsync(fileShareName); Assert.NotNull(share3.Data.Metadata); Assert.AreEqual(share3.Data.ShareQuota, shareData.ShareQuota); Assert.AreEqual(share3.Data.Metadata, shareData.Metadata); }
public async Task FileShareAccessPolicy() { //update storage account to v2 StorageAccountUpdateParameters updateParameters = new StorageAccountUpdateParameters() { Kind = Kind.StorageV2 }; await _storageAccount.UpdateAsync(updateParameters); //create share string fileShareName = Recording.GenerateAssetName("testfileshare"); FileShare share = (await _fileShareCollection.CreateOrUpdateAsync(true, fileShareName, new FileShareData())).Value; // Prepare signedIdentifiers to set List <SignedIdentifier> sigs = new List <SignedIdentifier>(); DateTimeOffset datenow = Recording.Now; DateTimeOffset start1 = datenow.ToUniversalTime(); DateTimeOffset end1 = datenow.AddHours(2).ToUniversalTime(); DateTimeOffset start2 = datenow.AddMinutes(1).ToUniversalTime(); DateTimeOffset end2 = datenow.AddMinutes(40).ToUniversalTime(); var updateParameters2 = new FileShareData(); SignedIdentifier sig1 = new SignedIdentifier("testSig1", new AccessPolicy(startTime: start1, expiryTime: end1, permission: "rw")); SignedIdentifier sig2 = new SignedIdentifier("testSig2", new AccessPolicy(startTime: start2, expiryTime: end2, permission: "rwdl")); updateParameters2.SignedIdentifiers.Add(sig1); updateParameters2.SignedIdentifiers.Add(sig2); // Update share share = await share.UpdateAsync(updateParameters2); Assert.AreEqual(2, share.Data.SignedIdentifiers.Count); Assert.AreEqual("testSig1", share.Data.SignedIdentifiers[0].Id); Assert.AreEqual("rw", share.Data.SignedIdentifiers[0].AccessPolicy.Permission); }