Lab 07: Store and share data safely¶
At a glance
- Time: about 60 minutes
- Region: Southeast Asia
- You create: 1 storage account, 1 blob container, 1 file share and 1 virtual network (free)
- Clean up: delete the storage account and the virtual network at the end
What you will learn¶
- How to create and secure a storage account.
- How to store files as blobs in a private container, and share one safely with a SAS link.
- How to create an Azure Files share.
- How to restrict network access to a storage account.
What is different in this environment
- Your storage account uses locally-redundant storage (LRS). Geo-redundant storage isn't allowed here (
[LAB-P05A-STORAGE-SKU]). - The blob retention policy is 1 day, not 180 days, and you don't lock it.
- You give the storage roles to your group,
CLOUD-LAB-GRP-N, not to your own user account. You are only allowed to assign these two roles, and only to your own group. - You work in your own resource group. Each group may have only one storage account.
Before you start¶
- You are signed in to the lab directory (Getting started).
- Your lab resource group is
rg-CLOUD-LAB-GRP-N. ReplaceNwith your group number. - Delete the resources from Lab 06.
- Do this lab on one computer and one network, because you restrict access by your IP address.
Task 1: Create and configure a storage account¶
- Search for Storage accounts and select + Create.
-
On Basics:
Setting Value Resource group rg-CLOUD-LAB-GRP-NStorage account name stgrpNplus 5 random letters or digits, for examplestgrp12k7x3qRegion Southeast Asia Preferred storage type Azure Blob Storage or Azure Data Lake Storage Gen 2 Performance Standard Redundancy Locally-redundant storage (LRS) The name must be unique
A storage account name is used in a public web address, so it must be unique in all of Azure. Use 3 to 24 lowercase letters and digits only.
-
On Networking, set Public network access to Disable. Take the defaults on the other tabs, including Data protection (soft delete of 7 days).
- Select Review + create, then Create. When it finishes, select Go to resource.
Give your group access to the data¶
Start this now, because a new role takes about 10 minutes to work.
- In the storage account, select Access control (IAM) → + Add → Add role assignment.
- Select the role Storage Blob Data Contributor, then Next.
- Under Members, select + Select members and search for
CLOUD-LAB-GRP-N. Select your own group, then Select. - Select Review + assign.
- Repeat for the role Storage File Data Privileged Contributor.
Only your own group
The system only lets you assign these two roles to your own group. Any other role or group is refused. If you can't find your group in the list, tell your trainer.
Allow your own computer¶
- Select Security + networking → Networking.
- Under Public network access, select Manage. Set Public network access to Enabled, and the scope to Enable from selected networks.
- Under IPv4 addresses, select Add your client IPv4 address. Select Save.
Add a lifecycle rule¶
- Select Data management → Lifecycle management → Add a rule.
- Name
Movetocool. Select Next. - Set: If base blobs were last modified more than 30 days ago, then Move to cool storage.
- Select Add.
Think about it
Why does moving old blobs to the Cool tier lower the cost? What do you give up?
Review redundancy¶
Select Data management → Redundancy. Note the primary location and the redundancy type (LRS keeps three copies in one data center).
Task 2: Create and use secure blob storage¶
Create a container and a retention policy¶
- Select Data storage → Containers → + Container.
- Name
data, public access level Private (no anonymous access). Select Create. - Select the
…next todataand choose Access policy. -
Under Immutable blob storage, select Add policy. Set the type to Time-based retention and the period to 1 day. Select Save.
Don't lock the policy
Locking makes it permanent, and you aren't allowed to do it. A retention policy that is not locked can still be removed, so you can clean up later.
What the policy does
While the policy is on, a blob in data can't be changed or deleted for 1 day after it is created.
Upload a blob¶
Wait until about 10 minutes have passed since you assigned the roles.
- Open the container
dataand select Upload. - If you see an authorization message, switch the Authentication method to Microsoft Entra user account.
-
Select any small file. Expand Advanced and set:
Setting Value Blob type Block blob Block size 4 MiB Access tier Hot Upload to folder securitytest -
Select Upload. Check that the folder and file appear.
- Select the file and look at its
…menu: Download, Delete, Change tier, Acquire lease.
Try to open the blob from the internet¶
- Open the file, then select Copy to clipboard next to its URL.
- Paste it into a new private browser window.
- You see an XML error such as
ResourceNotFoundorPublicAccessNotPermitted. This is correct: the container is Private.
Share the blob with a SAS link¶
A shared access signature (SAS) is a link with temporary permission.
- On the file, select the
…menu → Generate SAS. -
Set:
Setting Value Signing method User delegation key Permissions Read Start yesterday Expiry tomorrow Allowed IP addresses leave blank -
Select Generate SAS token and URL, then copy the Blob SAS URL.
- Open the URL in a private browser window. You should see the file.
Think about it
The SAS link needs no sign-in. What could go wrong if someone forwards it? How does the expiry help?
Task 3: Create an Azure Files share and restrict access¶
Create the file share¶
- Select Data storage → File shares → + File share (it may be called Classic file share).
- Name
share1. Keep the default access tier, Transaction optimized. Leave backup off. - Select Review + create, then Create.
Use Storage browser¶
- Select Storage browser in the storage account.
- Select File shares and open
share1. - If you see an authorization error, switch the authentication to Microsoft Entra user account.
- Select Upload and upload any file. Optionally add a directory first.
Restrict access to one virtual network¶
- Search for Virtual networks and select + Create. Use your resource group, the name
vnet1, region Southeast Asia and the address space10.1.0.0/16. - Add a subnet named
defaultwith the range10.1.0.0/24. Select Review + create, then Create. -
Open
vnet1. Under Settings, select Service endpoints → + Add:Setting Value Service Microsoft.Storage Subnets default -
Select Add and wait until the status is Succeeded.
- Go back to the storage account → Security + networking → Networking → Public network access → Manage.
- Select Add a virtual network → Add existing virtual network, choose
vnet1and the subnetdefault, and select Add. - Under IPv4 addresses, delete your client IP address. Select Save.
- Go to Storage browser and refresh. Open
share1. - You should see a message such as not authorized to perform this operation. Your computer is no longer on the list, and only
vnet1is.
It can take a few minutes
The change can take a couple of minutes. You may still see the share's name but not its files.
Think about it
The block applies to the data, and you can still delete the storage account in the portal. Why is that?
Task 4: Clean up¶
- Open the container
data→…→ Access policy, and delete the retention policy. If the file is still protected, wait for the day to pass or ask your trainer. - Delete the storage account. Type its name to confirm.
- Delete
vnet1. - Check that your resource group has none of these resources.
Check your work¶
- Your storage account uses LRS and was created in Southeast Asia.
- The container
datais private. The blob URL failed, and the SAS URL worked. -
share1exists and holds a file. - After the network restriction, Storage browser could no longer read your data.
- Your resource group is empty again.
Key points¶
- A storage account holds blobs, files, queues and tables, and its name is part of its public address.
- Redundancy decides how many copies exist and where. Higher redundancy costs more.
- Private containers need authorization. A SAS gives temporary, limited access.
- A retention policy stops blobs from being changed or deleted for a set time.
- Network rules decide which networks can reach the data. They don't stop management of the account itself.