def set_share_properties(self): from azure.storage.fileshare import ShareClient share1 = ShareClient.from_connection_string(self.connection_string, "sharesamples3a") share2 = ShareClient.from_connection_string(self.connection_string, "sharesamples3b") # Create the share share1.create_share() share2.create_share() try: # [START set_share_properties] # Set the tier for the first share to Hot share1.set_share_properties(access_tier="Hot") # Set the quota for the first share to 3 share1.set_share_properties(quota=3) # Set the tier for the second share to Cool and quota to 2 share2.set_share_properties(access_tier=ShareAccessTier("Cool"), quota=2) # Get the shares' properties print(share1.get_share_properties().access_tier) print(share1.get_share_properties().quota) print(share2.get_share_properties().access_tier) print(share2.get_share_properties().quota) # [END set_share_properties] finally: # Delete the shares share1.delete_share() share2.delete_share()
def test_set_share_properties(self, storage_account_name, storage_account_key): self._setup(storage_account_name, storage_account_key) share1 = self._create_share("share1") share2 = self._create_share("share2") share1.set_share_quota(3) share1.set_share_properties(access_tier="Hot") share2.set_share_properties(access_tier=ShareAccessTier("Cool"), quota=2) # Act props1 = share1.get_share_properties() props2 = share2.get_share_properties() share1_quota = props1.quota share1_tier = props1.access_tier share2_quota = props2.quota share2_tier = props2.access_tier # Assert self.assertEqual(share1_quota, 3) self.assertEqual(share1_tier, "Hot") self.assertEqual(share2_quota, 2) self.assertEqual(share2_tier, "Cool") self._delete_shares()
def create_share_snapshot(self): # Instantiate the ShareClient from a connection string from azure.storage.fileshare import ShareClient share = ShareClient.from_connection_string(self.connection_string, "sharesamples1") # [START create_share] # Create share with Access Tier set to Hot share.create_share(access_tier=ShareAccessTier("Hot")) # [END create_share] try: # [START create_share_snapshot] share.create_snapshot() # [END create_share_snapshot] finally: # [START delete_share] share.delete_share(delete_snapshots=True)