Skip to content

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.
Diagram: a storage account with a private blob container and a file share. Your group gets two data roles, a SAS link opens one blob, and network rules allow your computer and then only the virtual network vnet1.
One storage account, and the three ways access is controlled: roles, a SAS link and network rules. Select the diagram to open it full size.

Before you start

  • You are signed in to the lab directory (Getting started).
  • Your lab resource group is rg-CLOUD-LAB-GRP-N. Replace N with 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

  1. Search for Storage accounts and select + Create.
  2. On Basics:

    Setting Value
    Resource group rg-CLOUD-LAB-GRP-N
    Storage account name stgrpN plus 5 random letters or digits, for example stgrp12k7x3q
    Region 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.

  3. On Networking, set Public network access to Disable. Take the defaults on the other tabs, including Data protection (soft delete of 7 days).

  4. 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.

  1. In the storage account, select Access control (IAM) → + Add → Add role assignment.
  2. Select the role Storage Blob Data Contributor, then Next.
  3. Under Members, select + Select members and search for CLOUD-LAB-GRP-N. Select your own group, then Select.
  4. Select Review + assign.
  5. 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

  1. Select Security + networking → Networking.
  2. Under Public network access, select Manage. Set Public network access to Enabled, and the scope to Enable from selected networks.
  3. Under IPv4 addresses, select Add your client IPv4 address. Select Save.

Add a lifecycle rule

  1. Select Data management → Lifecycle management → Add a rule.
  2. Name Movetocool. Select Next.
  3. Set: If base blobs were last modified more than 30 days ago, then Move to cool storage.
  4. 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

  1. Select Data storage → Containers → + Container.
  2. Name data, public access level Private (no anonymous access). Select Create.
  3. Select the … next to data and choose Access policy.
  4. 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.

  1. Open the container data and select Upload.
  2. If you see an authorization message, switch the Authentication method to Microsoft Entra user account.
  3. 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
  4. Select Upload. Check that the folder and file appear.

  5. Select the file and look at its … menu: Download, Delete, Change tier, Acquire lease.

Try to open the blob from the internet

  1. Open the file, then select Copy to clipboard next to its URL.
  2. Paste it into a new private browser window.
  3. You see an XML error such as ResourceNotFound or PublicAccessNotPermitted. This is correct: the container is Private.

A shared access signature (SAS) is a link with temporary permission.

  1. On the file, select the … menu → Generate SAS.
  2. Set:

    Setting Value
    Signing method User delegation key
    Permissions Read
    Start yesterday
    Expiry tomorrow
    Allowed IP addresses leave blank
  3. Select Generate SAS token and URL, then copy the Blob SAS URL.

  4. 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

  1. Select Data storage → File shares → + File share (it may be called Classic file share).
  2. Name share1. Keep the default access tier, Transaction optimized. Leave backup off.
  3. Select Review + create, then Create.

Use Storage browser

  1. Select Storage browser in the storage account.
  2. Select File shares and open share1.
  3. If you see an authorization error, switch the authentication to Microsoft Entra user account.
  4. Select Upload and upload any file. Optionally add a directory first.

Restrict access to one virtual network

  1. Search for Virtual networks and select + Create. Use your resource group, the name vnet1, region Southeast Asia and the address space 10.1.0.0/16.
  2. Add a subnet named default with the range 10.1.0.0/24. Select Review + create, then Create.
  3. Open vnet1. Under Settings, select Service endpoints → + Add:

    Setting Value
    Service Microsoft.Storage
    Subnets default
  4. Select Add and wait until the status is Succeeded.

  5. Go back to the storage account → Security + networking → Networking → Public network access → Manage.
  6. Select Add a virtual network → Add existing virtual network, choose vnet1 and the subnet default, and select Add.
  7. Under IPv4 addresses, delete your client IP address. Select Save.
  8. Go to Storage browser and refresh. Open share1.
  9. You should see a message such as not authorized to perform this operation. Your computer is no longer on the list, and only vnet1 is.

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

  1. 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.
  2. Delete the storage account. Type its name to confirm.
  3. Delete vnet1.
  4. 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 data is private. The blob URL failed, and the SAS URL worked.
  • share1 exists 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.