Create and Manage Azure Storage Account

Author

Reads 1.3K

Modern data center corridor with server racks and computer equipment. Ideal for technology and IT concepts.
Credit: pexels.com, Modern data center corridor with server racks and computer equipment. Ideal for technology and IT concepts.

To create an Azure Storage account, you'll need to navigate to the Azure portal and click on the "Create a resource" button. This will take you to a page where you can select "Storage account" from the list of available resources.

In the Azure portal, you can create a new Storage account by clicking on the "Create" button on the top left corner of the screen. This will open up a form where you can enter the required details such as name, resource group, and location.

Azure Storage accounts can be either general-purpose or blob storage, depending on your specific needs. General-purpose Storage accounts provide access to both blobs and files, while blob storage accounts are optimized for storing unstructured data such as images and videos.

To manage your Azure Storage account, you'll need to navigate to the "Storage accounts" page in the Azure portal and click on the three dots next to your Storage account name. From there, you can access various features such as configuring access keys, setting up data redundancy, and monitoring usage.

Creating an Azure Storage Account

Credit: youtube.com, How to create a storage account | Azure Portal Series

To create an Azure Storage Account, you can start by logging into your Azure account and finding 'Storage' under 'Data Services'. Click on 'Quick Create' and you'll be asked for an 'Account Name'. There are four options in the 'Replication' dropdown, which determine how your data is stored and replicated across different regions.

The options for replication are: Locally Redundant Storage, Zone-Redundant Storage, Geo-Redundant Storage, and Read-Access Geo-Redundant Storage. Each option has its own advantages and disadvantages, and the choice of which one to use depends on your specific needs and budget.

Here's a brief summary of the replication options:

Keep in mind that each replication option has its own price plan, and the 'Local Redundant' option is the cheapest of them all.

Creating

Creating an Azure Storage Account is a straightforward process that can be done through various methods. You can create one using the Azure Portal, Azure PowerShell, or Azure CLI.

Credit: youtube.com, 4. How to create Storage account on Azure Portal | Azure Data Engineer

To create an Azure Storage Account, you can find 'Storage' under 'Data Services' when you login into your Azure account. From there, click on 'Quick Create' and it will ask for 'Account Name'. You can choose from four options in the 'Replication' dropdown, which determines how your data is stored and replicated across different regions.

The four options are:

  • Locally redundant storage
  • Zone-redundant storage (available for blobs only)
  • Geo-redundant storage
  • Read-access geo-redundant storage

Each option has its own price plan, with 'Local Redundant' being the cheapest. You can choose the replication option that best suits your needs and budget.

To create a storage account using the Azure CLI, you can use the command 'az storage account create'. This will create a storage account with the default SKU of 'Standard_RAGRS'. You can also use the 'storage-preview extension' to allow or disallow public access to all blobs or containers in the storage account.

If you want to create a storage account using Python, you can use the Azure Storage Blobs client library. To create a client, you need the storage account's blob service account URL and a credential that allows you to access the storage account.

Prerequisites

Credit: youtube.com, FalconTek Solutions Central - Prerequisite Video 1 – Azure Data Factory – Create a Azure Blob Storag

To create an Azure Storage Account, you'll need to meet a few prerequisites.

Python 3.8 or later is required to use this package, so make sure your Python version is up to date.

You'll also need an Azure subscription and an Azure storage account to use this package. An Azure subscription is like a key to unlock the entire Azure platform, and a storage account is where you'll store your data.

To access blob data from your local environment, you'll need permissions and a shared access signature (SAS) token.

See what others are reading: Azure Blob Storage Access

How It Works

Creating an Azure Storage Account involves connecting to Azure services, and to do that, you use the Azure SDK for Python.

Airflow uses this SDK to connect to Azure services through the WasbHook.

The WasbHook is a key component in this process, allowing for seamless integration with Azure services.

Airflow relies on the WasbHook to facilitate this connection, making it easier to manage and access your Azure Storage Account.

Consider reading: Azure Data Storage Options

Azure CLI Commands

Credit: youtube.com, Create Storage Account from Azure CLI | AWS CLI Tutorial | Azure Storage Account

You can create a storage account using the Azure CLI command `az storage account create`. This command defaults to the 'Standard_RAGRS' SKU.

To generate a shared access signature for your storage account, use the command `az storage account generate-sas`. This command allows you to specify the permissions, resource types, and storage services the SAS grants.

You can also get the connection string for a storage account using the command `az storage account show-connection-string`. This command can be used to get a connection string for a storage account or its custom endpoint for blobs.

Check-Name

The Check-Name command is a crucial tool in Azure CLI. It checks that the storage account name is valid and not already in use.

You can use the az storage account check-name command to verify the name of the storage account within a specified resource group.

Increase logging verbosity with the --debug flag for full debug logs.

On a similar theme: How to See Onedrive Storage

Az Create

Az Create is a powerful command in Azure CLI that allows you to create a storage account.

Consider reading: Create Azure Blob Storage

Credit: youtube.com, Azure CLI Tutorial

The SKU of the storage account defaults to 'Standard_RAGRS' when you use the az storage account create command.

You can also use the Azure Portal, Azure PowerShell, or Azure CLI to create a new storage account.

The az storage account create command allows you to restrict copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet.

The minimum TLS version to be permitted on requests to storage defaults to TLS 1.0 for this property.

You can use the az storage account create (storage-preview extension) command to allow or disallow public access to all blobs or containers in the storage account.

Install the Package

To install the Azure CLI, you'll want to start with the basics. Install the Azure CLI on your machine by running the command "az --version" to check if it's already installed, or "az login" to install it if not.

The Azure Storage Blobs client library for Python can be installed with pip. Install it by running "pip install azure-storage-blob" in your terminal or command prompt.

Managing Azure Storage Account

Credit: youtube.com, How to manage a storage account | Azure Portal Series

You can upload or download data to Azure storage by creating your own application, using an already built tool, or accessing it through the 'Storage Explorer' under 'Get the Tools' in your Azure storage account.

To access the Storage Explorer, click on it under 'Get the Tools' in your Azure storage account, or build an application using the Software Development Kit (SDK) available in the Windows Azure Portal.

You can also use PowerShell commands to upload data, which is a command line application that facilitates administering and managing the Azure storage.

For another approach, see: Azure Blob Explorer

Az Show-Connection-String

Az Show-Connection-String is a command that allows you to retrieve the connection string for a storage account. This connection string is a crucial piece of information that enables you to connect to your storage account.

You can use the Az Show-Connection-String command to get the connection string for a storage account. This can be done by specifying the storage account name, key, or service endpoint. For example, you can use the AZURE_STORAGE_ACCOUNT environment variable to specify the storage account name.

Credit: youtube.com, How to get Azure Storage Account Connection String | Azure Storage Account Connection String

The connection string can also be retrieved using the AZURE_STORAGE_KEY environment variable in conjunction with the storage account name. Alternatively, you can use the AZURE_STORAGE_SERVICE_ENDPOINT environment variable to specify the storage service endpoint.

The connection string is a string that includes the storage account name, account key, and other relevant information. It's used to authenticate and authorize access to the storage account.

Managing Data

You can upload or download data to Azure Storage through various means, but not directly within the Azure portal itself. You'll need to create your own application or use an existing tool.

One option is to use the Storage Explorer, which can be accessed by clicking on 'Storage Explorer' under 'Get the Tools' in your Azure storage account. This allows you to access your data in an explorer.

Another approach is to build an application using the Software Development Kit (SDK) available in the Windows Azure Portal. This gives you the flexibility to tailor your data management to your specific needs.

You can also use PowerShell commands to upload data. PowerShell is a command-line application that simplifies the process of administering and managing Azure Storage.

Uploading a Blob

Credit: youtube.com, Azure Blob Storage: Managing Blobs in Azure Storage Accounts

Uploading a blob is a straightforward process that can be accomplished using the async client. The async client is a powerful tool that allows you to upload blobs efficiently.

To upload a blob, you'll need to use the async client, as mentioned in the example. This is the best approach for uploading blobs, especially when working with large files.

Using the async client will save you time and reduce the risk of errors, as it handles the upload process asynchronously. This means you can continue working on other tasks while the upload completes in the background.

The example shows how to use the async client to upload a blob, making it easy to follow along and replicate the process in your own projects.

Azure Storage Account Configuration

To get started with Azure Storage Account configuration, you'll want to retrieve the connection string for your storage account. This can be done using the command `az storage account show-connection-string`.

Credit: youtube.com, 3 | Azure Storage Account Setup: Step-by-Step Tutorial

The connection string is a crucial piece of information that allows you to connect to your storage account. You can get a connection string for a storage account using the same command.

Custom endpoints for blobs are also an important aspect of Azure Storage Account configuration. This allows you to specify a custom endpoint for blob storage, giving you more control over how your data is accessed and managed.

Encryption Configuration

Encryption Configuration is a crucial aspect of securing your Azure Storage Account. To configure encryption, you'll need to use specific keyword arguments when instantiating a client.

The require_encryption argument is a boolean that enforces encryption and decryption of objects. Set it to True to ensure all data is encrypted.

The encryption_version argument specifies the version of encryption to use. Currently, you can choose between '2.0' and '1.0', with '2.0' being the recommended option due to its deprecation of version '1.0'.

Credit: youtube.com, Storage Account service Encryption Azure KeyVault secret key encryption

If you decide to use version '2.0', make sure your key_encryption_key object implements the necessary methods.

You can also provide a user-provided key resolver function, which returns a key-encryption-key using the kid string.

Here's a quick rundown of the encryption configuration options:

Retry Policy Configuration

When configuring your Azure Storage Account, it's essential to consider the retry policy. This determines how your application will handle failed requests.

The retry policy is configured using keyword arguments when instantiating a client. You can specify the total number of retries allowed with the retry_total argument.

The retry_total argument takes precedence over other counts and defaults to 10. If you don't want to retry on requests at all, you can pass in retry_total=0.

You can also configure the number of connection-related errors to retry on with the retry_connect argument. This defaults to 3.

Similarly, you can specify how many times to retry on read errors with the retry_read argument. This also defaults to 3.

For more insights, see: Azure Blob Storage Retention Policy

Credit: youtube.com, Access Policy -Azure Storage account

If you're using RA-GRS accounts and potentially stale data can be handled, you can enable retrying to secondary with the retry_to_secondary argument. This defaults to False.

Here's a summary of the retry policy configuration arguments:

Optional Parameters

You can allow or disallow public access to all blobs or containers in the storage account. The default value for this property is null, which is equivalent to true.

Setting this property to true does not enable anonymous access to any data in the account, an additional step of configuring the public access setting for a container is required to enable anonymous access.

Restricting copy to and from Storage Accounts within an AAD tenant or with Private Links to the same VNet is also an option.

The minimum TLS version to be permitted on requests to storage can be set, with the default interpretation being TLS 1.0 for this property.

You can specify the IP address or range of IP addresses from which to accept requests, supporting only IPv4 style addresses.

Credit: youtube.com, Azure Storage Account Configuration in v1 portal & in v2 portal

The SAS becomes invalid at a specified UTC datetime, which can be set when generating a shared access signature for the storage account.

The SAS becomes valid at a specified UTC datetime, which defaults to the time of the request when generating a shared access signature for the storage account.

The permissions the SAS grants can be specified, with allowed values including add, create, delete, filter_by_tags, and more.

The resource types the SAS is applicable for can be specified, with allowed values including service, container, and object.

The storage services the SAS is applicable for can be specified, with allowed values including blob, file, queue, and table.

You can specify the storage account key, which must be used in conjunction with the storage account name or service endpoint.

You can specify the storage account name, which must be used in conjunction with either the storage account key or a SAS token.

You can specify the storage data service endpoint, which must be used in conjunction with either the storage account key or a SAS token.

You can specify a custom endpoint for blobs when getting the connection string for a storage account.

Azure Storage Account Access

Credit: youtube.com, How to create storage accounts and connect Azure Storage Explorer to access locally? - Azure 2023

You can access your Azure Storage account using various methods, including shared access keys, connection strings, and SAS tokens.

Two access keys are provided in order to access the account without interrupting it, in case one key has to be regenerated. Regenerating the key at regular intervals is advised for security reasons.

To access your storage account using a shared access key, you'll need the name of the storage account and the shared access key itself. You can find these values in the Azure Portal under the "Access Keys" section.

A connection string for a storage account includes the authorization information required to access data in your storage account. You can find the connection string in the Azure Portal under the "Access Keys" section.

To use a SAS token, you can generate one from the Azure Portal under "Shared access signature" or use one of the generate_sas() functions to create a sas token for the storage account, container, or blob.

Credit: youtube.com, How to create Azure Storage account and upload files to Azure blob storage | 2024 update

You can also use a storage account shared key (aka account key or access key) to authenticate the client. This can be found in the Azure Portal under the "Access Keys" section or by running the following Azure CLI command: az storage account keys list -g MyResourceGroup -n MyStorageAccount.

Here's a summary of the types of credentials you can use to access your Azure Storage account:

Remember to use the correct credential type for your specific use case to ensure secure and reliable access to your Azure Storage account.

Troubleshooting

Troubleshooting can be a challenge when working with Azure Storage. Storage Blob clients raise exceptions defined in Azure Core.

If you're encountering issues, you can use the list of exceptions as a reference to catch thrown exceptions. This will help you identify the specific error code associated with the exception.

The error code can be retrieved using the error_code attribute, i.e., exception.error_code. This attribute is crucial in pinpointing the exact cause of the problem.

You can refer to sections 12.14.1 and 12.7.1 for more information on specific exceptions and their error codes.

Gilbert Deckow

Senior Writer

Gilbert Deckow is a seasoned writer with a knack for breaking down complex technical topics into engaging and accessible content. With a focus on the ever-evolving world of cloud computing, Gilbert has established himself as a go-to expert on Azure Storage Options and related topics. Gilbert's writing style is characterized by clarity, precision, and a dash of humor, making even the most intricate concepts feel approachable and enjoyable to read.

Love What You Read? Stay Updated!

Join our community for insights, tips, and more.