We now have an app that can take a photograph and check for happy faces.
We now need to be able to upload this photo to Azure so it can be shared with other users of our app. For this we will be using two types of storage that you will configure from the Azure portal - blob storage to store the actual photos as raw binary blobs (Binary Large OBject), and Cosmos DB to save metadata about each image.
In Azure Blob Storage, blobs are stored in containers, similar to how a folder holds files on a PC. We will be creating our container using the Azure Portal UI, but containers can also be created in code.
-
In the Azure Portal, navigate to the Azure Storage resource, happyxamdevs[Your Last Name]
-
On the Azure Storage page, on the left-hand menu, select Blobs
-
On the Blobs page, select + Container
-
In the New Container window, enter the following"
- Name: photos
- Public access level: Private (no anonymous access)
-
In the New Container window, click OK
The second type of storage to configure is Cosmos DB. This is a NoSQL database that we will use to store metadata about the uploaded photos.
-
On the Azure Portal, click the + Create Resource button
Note: The + Create Resource button will be a green + if the sidebar is collapsed
-
In the New page, in the search bar, enter Cosmos Db
-
On the keyboard, press the Return key
-
In the search results, select Azure Cosmos DB
-
In the Azure Cosmos Db pane, click Create
-
In the Create Azure Cosmos DB Account page, enter the following:
- Subscription: [Select Your Azure Subscription]
- Resource Group: HappyXamDevs
- Account Name: happyxamdevs-[Your Last Name]
- E.g. happyxamdevs-minnick
Note: The Storage Account Name must be unique because it is used as the subdomain for our Azure Cosmos Db url
- API: Core (SQL)
- Apache Spark: None
Note: Thfe different APIs have different ways for you to access and query your data, and have different capabilities. The SQL API allows us to query our data using SQL, and supports binding to Azure Functions which we will do in a later section
- Location: WestUS
- GeoRedundancy Disable
- Multi-region Writes Disable
- Subscription: [Select Your Azure Subscription]
-
In the Create Azure Cosmos DB Account page, click Review + create
-
In the Create Azure Cosmos DB Account page, click Create
We will create a database that contains a collection in which we will add our photos metadata.
-
In the Azure Portal, navigate to the newly created Cosmos Db resource, happyxamdevs-[Your Last Name]
- E.g. happyxamdevs-minnick
-
On the CosmosDb page, on the left-hand menu, select Data Explorer
-
In the Data Explorer page, click New Container
-
In the New Collection pane, enter the following:
- Database id
- Create New
- Type a new database id: Photos
- Provision database throughput
- Container Id: PhotoMetadata
- Partition Key: /name
- Throughput: 400
- Database id
-
In the New Collection pane, click OK
Now that you have storage configured, the next step is to create an Azure Function to save the photos to blob storage.