Sie sind auf Seite 1von 2

1.

Objective - Develop solutions that use Cosmos DB storage


1. Select Home > Resource groups, then choose your resource group, such as oreilly-az300
2. At the top of the resource group window select + Add, search for and select “azure cosmos
db”, then choose Create. Enter the following configuration information. If not noted below,
use the defaults:

Resource group: oreilly-az300


Account name: az300-training-<yourinitials-or-random-value>
API: Core (SQL)
Apache Spark: None
Location: West US
For now, leave geo-redundancy and multi-region writes as disabled.
3. Leave the Networking options for now and select Review + create. When ready, select
Create
4. If needed, select the notification bell in the top right-hand corner to view deployment
progress as the Cosmos DB instance is created. It takes a few minutes to create the Cosmos
DB instance.
5. When ready, select Go to resource

2. Objective – Implement global replication with Cosmos DB


1. From your Cosmos DB account, select Settings > Replicate data globally on the left-hand
side. Select some regions on the map, such as East US or Australia Central. Some regions,
like East US can also use Availability Zones for even great availability and resiliency.
2. By default, only one region is designated for writes to the account. The other regions are for
read operations, or in the event the service needs to failover to another region for writes.
You can choose to Enable Multi-region writes. This ability lets multiple regions receive write
requests which are then replicated using the defined consistency level.
3. When ready, select Save. It can take a few minutes to enable the replication.

Note that SQL Databases could also be geo-replicated, but required additional configuration
to create, configure, and pay for SQL Server instances in the required regions. Cosmos DB
abstracts that and doesn’t require additional configuration.

3. Objective – Create, read, update, and delete data with Cosmos DB


1. From your Cosmos DB account, select Data Explorer on the left-hand side, then choose New
container. Enter the following configuration information. If not noted below, use the
defaults:

Database id: Create new, enter a name such as az300-training

Provision database throughput: Checked


Leave the default setting of Manual and 400 RUs. Note the (currently) preview option
for Autopilot that gives you the option to define maximum RUs instead.

Container id: training

Partition key: /course

2. When ready, select OK.


3. The Data Explorer updates to show your az300-training container. Select it to expand the
menu. On the Scale menu, you can change the number of RUs to assign.
4. If you expand on training, you can then select Items, and note the options for things like
Stored Procedures or User Defined Functions.

You can add a New item or Upload item. Items are provided in JSON format, and there’s no
defined schema as with a traditional SQL database.

Enter the following JSON item:


{

"id": "001",
"company": "o'reilly",
"course": "az-300 boot camp"
}

5. Select Save and note that Cosmos DB then adds additional data to the item. This data is
used to help query and retrieve data as needed.
6. Select you training container in the left-hand navigation window of the Data Explorer, select
the … menu option, and choose New SQL query
7. On line 1 of the query editor, enter the following query:

SELECT c.company,c.course FROM c

8. When ready, select Execute query. Only the company and course data is returned, not all
the additional data shown when you created the item. Queries in Cosmos DB, depending on
API used, are similar to regular SQL queries.
9. Go back to the Items menu, and select the 001 record you created. At the top, select Delete
and confirm you wish to delete the item.

Behind the scenes, the item create and delete requests are also replicated across the
geographies selected in the previous exercise.

Das könnte Ihnen auch gefallen