Skip to content

Storing files and things with DB #30

Description

Week 3 Step 1 ⬤◯◯◯◯◯◯◯◯ | 🕐 Estimated completion: 5-20 minutes

Blob Storage & Me

This week, you will be going through steps to set up a Blob storage container along with its account. If you are already familiar with this, feel free to skip to the end and complete the task to move on.

✅ Task:

  • Create a new branch called bunnimage
  • 1: Create a Blob storage account and container with a blob access level
  • 2: Create a new Azure function called bunnimage-upload with the HTTP trigger template and install NPM packages
    • parse-multipart
    • node-fetch
    • @azure/storage-blob (install version 12.2.1)
  • 🚀 Store your Azure Blob Storage account access keys (container name and connection string) as secrets called container_name and storage_account_connection_string and commit your starter (template) function code to bunnimage-upload/index.js on the bunnimage branch
  • 🚀 Create a pull request that merges bunnimage to main, but do not merge it

1. Creating a Blob Storage Account and its Resources

Azure Blob storage is solution that can store massive amounts of unstructured data, like text, images, or videos. Read more about it here!

A storage account provides a unique namespace in Azure for your data. Every object that you store in Azure Storage has an address that includes your unique account name. The combination of the account name and the Azure Storage blob endpoint forms the base address for the objects in your storage account.

For example, if your storage account is named mystorageaccount, then the default endpoint for Blob storage is: http://mystorageaccount.blob.core.windows.net

❗ Create a Blob Storage Account
  1. Navigate to your Azure portal.

  2. In the Search Bar, search and click on "Storage accounts".

    image

  3. Click on "Create storage account".

    image

  4. Fill out the storage account details like below, and click "Review + create".

    image

  5. Click "Create".

    image

  6. Wait for the screen to display "Your deployment is complete". Click "Go to resource". You're ready to create your Blob Storage container!

    image



❗ Access your Azure Blob Storage account access key
  1. Navigate to your storage account page.

  2. On the left hand bar, click on Security + networking > Access Keys.

    image

  3. Click "Show keys", and you can copy one of the connection strings' information.



❗ Create a Blob Storage Container!
  1. Make sure you're on your storage account page in the Azure portal.

  2. In the left menu for the storage account, scroll to the Data storage section, then select Containers.

  3. Select the + Container button.

  4. Type a name for your new container. The container name must be lowercase, must start with a letter or number, and can include only letters, numbers, and the dash (-) character.

  5. Set the level of public access to the container to "Blob (anonymous read access for blobs only)".

    image

  6. Select Create to create the container.


2: Creating an HTTP Trigger Function and Installing Required Packages:

Create a new HTTP trigger function named bunnimage-upload (no need to edit the code yet). Feel free to navigate to the previous issues/steps for guidance if you need extra help.

Before we start coding the trigger, we need to install the following npm packages/libraries in the Function App we created in the previous step:

  1. parse-multipart
  2. node-fetch
  3. @azure/storage-blob

Tip: To install a specific version of the Azure package run: npm i @azure/storage-blob@12.2.1

❓ How do I install `npm` packages?

Click on the "Console" tab in the left panel under "Development Tools".

https://user-images.githubusercontent.com/69332964/99189070-59e31d00-272d-11eb-80a4-17444e5fac65.png

Inside the console (shown on the right panel), type in the following commands:

npm init -y

npm install parse-multipart

npm install node-fetch

npm install @azure/storage-blob

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions