快速入门:生成 Java 应用以管理 Azure Cosmos DB SQL API 数据Quickstart: Build a Java app to manage Azure Cosmos DB SQL API data

在本快速入门中,你将通过 Azure 门户并使用从 GitHub 克隆的 Java 应用来创建和管理 Azure Cosmos DB SQL API 帐户。In this quickstart, you create and manage an Azure Cosmos DB SQL API account from the Azure portal, and by using a Java app cloned from GitHub. 首先,请使用 Azure 门户创建 Azure Cosmos DB SQL API 帐户,使用 SQL Java SDK 创建 Java 应用,然后使用 Java 应用程序将资源添加到 Cosmos DB 帐户。First, you create an Azure Cosmos DB SQL API account using the Azure portal, then create a Java app using the SQL Java SDK, and then add resources to your Cosmos DB account by using the Java application. Azure Cosmos DB 是一种多模型数据库服务,可让你通过多区域分布和水平缩放功能快速创建和查询文档、表、键/值和图数据库。Azure Cosmos DB is a multi-model database service that lets you quickly create and query document, table, key-value, and graph databases with multiple-region distribution and horizontal scale capabilities.

重要

本快速入门仅适用于 Azure Cosmos DB Java SDK v4。This quickstart is for Azure Cosmos DB Java SDK v4 only. 请查看 Azure Cosmos DB Java SDK v4 发行说明Maven 存储库、Azure Cosmos DB Java SDK v4 性能提示和 Azure Cosmos DB Java SDK v4 故障排除指南了解详细信息。Please view the Azure Cosmos DB Java SDK v4 Release notes, Maven repository, Azure Cosmos DB Java SDK v4 performance tips, and Azure Cosmos DB Java SDK v4 troubleshooting guide for more information. 如果你当前使用的是早于 v4 的版本,请参阅迁移到 Azure Cosmos DB Java SDK v4 指南,获取升级到 v4 的相关帮助。If you are currently using an older version than v4, see the Migrate to Azure Cosmos DB Java SDK v4 guide for help upgrading to v4.

先决条件Prerequisites

  • 具有活动订阅的 Azure 帐户。An Azure account with an active subscription. 免费创建一个Create one for free. 你还可以使用 Azure Cosmos DB 模拟器以及 URI https://localhost:8081 和密钥 C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==You can also use the Azure Cosmos DB Emulator with a URI of https://localhost:8081 and the key C2y6yDjf5/R+ob0N8A7Cgv30VRDJIWEHLM+4QDU5DE2nQ9nDuVTqobD4b8mGGyPMbIZnqyMsEcaGQy67XIw/Jw==.

  • Java 开发工具包 (JDK) 8Java Development Kit (JDK) 8. JAVA_HOME 环境变量指向其中安装了 JDK 的文件夹。Point your JAVA_HOME environment variable to the folder where the JDK is installed.

  • Maven 二进制存档A Maven binary archive. 在 Ubuntu 上运行 apt-get install maven,以安装 Maven。On Ubuntu, run apt-get install maven to install Maven.

  • GitGit. 在 Ubuntu 上运行 sudo apt-get install git,以安装 Git。On Ubuntu, run sudo apt-get install git to install Git.

介绍性说明Introductory notes

Cosmos DB 帐户的结构。The structure of a Cosmos DB account. 不管使用 API 还是编程语言,都具有以下特点:一个 Cosmos DB 帐户包含零个或零个以上的数据库,一个数据库 (DB) 包含零个或零个以上的容器,一个容器包含零个或零个以上的项,如下图所示:Irrespective of API or programming language, a Cosmos DB account contains zero or more databases, a database (DB) contains zero or more containers, and a container contains zero or more items, as shown in the diagram below:

Azure Cosmos 帐户实体

可在此处阅读有关数据库、容器和项的详细信息。You may read more about databases, containers and items here. 几个重要属性在容器级别定义,其中包括预配吞吐量和分区键。A few important properties are defined at the level of the container, among them provisioned throughput and partition key.

预配吞吐量以具有货币价格的请求单位 (RU) 度量,是帐户运营成本中重要的确定性因素。The provisioned throughput is measured in Request Units (RUs) which have a monetary price and are a substantial determining factor in the operating cost of the account. 可以按单容器粒度或单数据库粒度选择预配吞吐量,但通常首选容器级别吞吐量规范。Provisioned throughput can be selected at per-container granularity or per-database granularity, however container-level throughput specification is typically preferred. 可在此处阅读有关吞吐量预配的详细信息。You may read more about throughput provisioning here.

将项插入 Cosmos DB 容器时,数据库会添加更多的存储和计算来处理请求,以水平方式增长。As items are inserted into a Cosmos DB container, the database grows horizontally by adding more storage and compute to handle requests. 存储和计算容量添加到称为分区的离散单元中,你必须在文档中选择一个字段作为分区键,以便将每个文档映射到分区。Storage and compute capacity are added in discrete units known as partitions, and you must choose one field in your documents to be the partition key which maps each document to a partition. 分区的管理方式是从分区键值的范围内为每个分区分配一个大致相等的切片;因此,建议选择相对随机或均匀分布的分区键。The way partitions are managed is that each partition is assigned a roughly equal slice out of the range of partition key values; therefore you are advised to choose a partition key which is relatively random or evenly-distributed. 否则,某些分区看到的请求数会多得多(热分区),而其他分区看到的请求数会少得多(冷分区),这是应该避免的。Otherwise, some partitions will see substantially more requests (hot partition) while other partitions see substantially fewer requests (cold partition), and this is to be avoided. 可以在此处详细了解分区。You may learn more about partitioning here.

创建数据库帐户Create a database account

在创建文档数据库之前,需通过 Azure Cosmos DB 创建 SQL API 帐户。Before you can create a document database, you need to create a SQL API account with Azure Cosmos DB.

  1. 在 Azure 门户菜单或主页中,选择“创建资源” 。From the Azure portal menu or the Home page, select Create a resource.

  2. 在“新建”页面中搜索“Azure Cosmos DB”,然后选择它。 On the New page, search for and select Azure Cosmos DB.

  3. 在“Azure Cosmos DB”页上,选择“创建”。On the Azure Cosmos DB page, select Create.

  4. 在“创建 Azure Cosmos DB 帐户”页上,输入新 Azure Cosmos 帐户的基本设置。On the Create Azure Cosmos DB Account page, enter the basic settings for the new Azure Cosmos account.

    设置Setting Value 说明Description
    订阅Subscription 订阅名称Subscription name 选择要用于此 Azure Cosmos 帐户的 Azure 订阅。Select the Azure subscription that you want to use for this Azure Cosmos account.
    资源组Resource Group 资源组名称Resource group name 选择一个资源组,或者选择“新建”,然后输入新资源组的唯一名称。Select a resource group, or select Create new, then enter a unique name for the new resource group.
    帐户名Account Name 唯一的名称A unique name 输入标识此 Azure Cosmos 帐户的名称。Enter a name to identify your Azure Cosmos account. 由于 documents.azure.cn 将追加到所提供的名称以创建 URI,因此,请使用唯一的名称**。Because documents.azure.cn is appended to the name that you provide to create your URI, use a unique name.

    名称只能包含小写字母、数字和连字符 (-)。The name can only contain lowercase letters, numbers, and the hyphen (-) character. 它的长度必须介于 3-44 个字符之间。It must be between 3-44 characters in length.
    APIAPI 要创建的帐户的类型The type of account to create 选择“Core (SQL)”,以便使用 SQL 语法创建文档数据库并进行查询。Select Core (SQL) to create a document database and query by using SQL syntax.

    API 确定要创建的帐户的类型。The API determines the type of account to create. Azure Cosmos DB 提供五种 API:适用于文档数据的 Core (SQL) 和 MongoDB、适用于图形数据的 Gremlin、Azure 表和 Cassandra。Azure Cosmos DB provides five APIs: Core (SQL) and MongoDB for document data, Gremlin for graph data, Azure Table, and Cassandra. 目前,你必须为每种 API 创建单独的帐户。Currently, you must create a separate account for each API.
    应用免费层折扣Apply Free Tier Discount 应用或不应用Apply or Do not apply 使用 Azure Cosmos DB 免费层,你将在帐户中获得每秒的前 400 RU 免费的吞吐量和 5 GB 的免费存储。With Azure Cosmos DB free tier, you will get the first 400 RU/s and 5 GB of storage for free in an account. 了解免费层的详细信息。Learn more about free tier.
    位置Location 离用户最近的区域The region closest to your users 选择用于托管 Azure Cosmos DB 帐户的地理位置。Select a geographic location to host your Azure Cosmos DB account. 使用离用户最近的位置,使他们能够以最快的速度访问数据。Use the location that is closest to your users to give them the fastest access to the data.
    帐户类型Account Type 生产或非生产Production or Non-Production 如果帐户将用于生产工作负荷,请选择“生产”。Select Production if the account will be used for a production workload. 如果帐户将用于非生产环境(例如开发、测试、QA 或过渡),请选择“非生产”。Select Non-Production if the account will be used for non-production, e.g. development, testing, QA, or staging. 这是一个 Azure 资源标记设置,用于调整门户体验,但不会影响基础 Azure Cosmos DB 帐户。This is an Azure resource tag setting that tunes the Portal experience but does not affect the underlying Azure Cosmos DB account. 可以随时更改此值。You can change this value anytime.

    备注

    每个 Azure 订阅最多可以有一个免费层 Azure Cosmos DB 帐户,并且你必须在创建帐户时选择加入使用。You can have up to one free tier Azure Cosmos DB account per Azure subscription and must opt-in when creating the account. 如果看不到用于应用免费层折扣的选项,这意味着订阅中的另一个帐户已启用免费层。If you do not see the option to apply the free tier discount, this means another account in the subscription has already been enabled with free tier.

    Azure Cosmos DB 的“新建帐户”页面

  5. 选择“查看 + 创建”。Select Review + create. 可以跳过“网络”和“标记”部分 。You can skip the Network and Tags sections.

  6. 检查帐户设置,然后选择“创建”。Review the account settings, and then select Create. 创建帐户需要几分钟时间。It takes a few minutes to create the account. 等待门户页显示“你的部署已完成”消息。Wait for the portal page to display Your deployment is complete.

    Azure 门户“通知”窗格

  7. 选择“转到资源”,转到 Azure Cosmos DB 帐户页。Select Go to resource to go to the Azure Cosmos DB account page.

    Azure Cosmos DB 帐户页面

添加容器Add a container

现在可以在 Azure 门户中使用数据资源管理器工具来创建数据库和容器。You can now use the Data Explorer tool in the Azure portal to create a database and container.

  1. 选择“数据资源管理器” > “新建容器”。 Select Data Explorer > New Container.

    “添加容器”区域显示在最右侧,可能需要向右滚动才能看到它。The Add Container area is displayed on the far right, you may need to scroll right to see it.

    Azure 门户 >“数据资源管理器”>“添加集合”窗格

  2. 在“添加容器”页中,输入新容器的设置。In the Add container page, enter the settings for the new container.

    设置Setting 建议的值Suggested value 说明Description
    数据库 IDDatabase ID 任务Tasks 输入 Tasks 作为新数据库的名称。Enter Tasks as the name for the new database. 数据库名称必须包含 1 到 255 个字符,不能包含 /, \\, #, ? 或尾随空格。Database names must contain from 1 through 255 characters, and they cannot contain /, \\, #, ?, or a trailing space. 选中“预配数据库吞吐量”选项,这样就可以在数据库中的所有容器之间共享预配给该数据库的吞吐量。Check the Provision database throughput option, it allows you to share the throughput provisioned to the database across all the containers within the database. 此选项还有助于节省成本。This option also helps with cost savings.
    吞吐量Throughput 400400 将吞吐量保留为每秒 400 个请求单位 (RU/s)。Leave the throughput at 400 request units per second (RU/s). 如果想要减少延迟,以后可以增加吞吐量。If you want to reduce latency, you can scale up the throughput later.
    容器 IDContainer ID ItemsItems 输入 Items 作为新容器的名称。Enter Items as the name for your new container. 容器 ID 与数据库名称的字符要求相同。Container IDs have the same character requirements as database names.
    分区键Partition key /category/category 本文中所述的示例使用 /category 作为分区键。The sample described in this article uses /category as the partition key.

    除了前面的设置,还可以选择为容器添加“唯一键”。In addition to the preceding settings, you can optionally add Unique keys for the container. 在此示例中,请将此字段留空。Let's leave the field empty in this example. 开发人员可以使用唯一键向数据库添加一层数据完整性。Unique keys provide developers with the ability to add a layer of data integrity to the database. 创建容器时,通过创建唯一键策略,可确保每个分区键的一个或多个值的唯一性。By creating a unique key policy while creating a container, you ensure the uniqueness of one or more values per partition key. 若要了解详细信息,请参阅 Azure Cosmos DB 中的唯一键一文。To learn more, refer to the Unique keys in Azure Cosmos DB article.

    选择“确定”。Select OK. 数据资源管理器将显示新的数据库和容器。The Data Explorer displays the new database and container.

添加示例数据Add sample data

现在可以使用数据资源管理器将数据添加到新容器。You can now add data to your new container using Data Explorer.

  1. 在“数据资源管理器”中展开“Tasks”数据库,然后展开“Items”容器。 From the Data Explorer, expand the Tasks database, expand the Items container. 选择“项”,然后单击“新建项”。 Select Items, and then click New Item.

    在 Azure 门户的数据资源管理器中创建新文档

  2. 现在,将文档添加到具有以下结构的容器。Now add a document to the container with the following structure.

    {
        "id": "1",
        "category": "personal",
        "name": "groceries",
        "description": "Pick up apples and strawberries.",
        "isComplete": false
    }
    
  3. 将 json 添加到“文档”选项卡以后,即可选择“保存”。 Once you've added the json to the Documents tab, select Save.

    通过复制添加 JSON 数据,然后在 Azure 门户上的数据资源管理器中选择“保存”

  4. 再创建并保存一个文档,在其中插入 id 属性的唯一值,并将其他属性更改为适当值。Create and save one more document where you insert a unique value for the id property, and change the other properties as you see fit. 新文档可以具有所需的任何结构,因为 Azure Cosmos DB 不对数据施加任何架构。Your new documents can have any structure you want as Azure Cosmos DB doesn't impose any schema on your data.

查询数据Query your data

可以在数据资源管理器中使用查询来检索和筛选数据。You can use queries in Data Explorer to retrieve and filter your data.

  1. 在数据资源管理器的“项”选项卡顶部,查看默认查询 SELECT * FROM cAt the top of the Items tab in Data Explorer, review the default query SELECT * FROM c. 此查询检索并显示容器中按 ID 排序的所有文档。This query retrieves and displays all documents from the container ordered by ID.

    数据资源管理器中的默认查询是“SELECT * FROM c”

  2. 若要更改查询,请选择“编辑筛选器”,将默认查询替换为 ORDER BY c._ts DESC,然后选择“应用筛选器”。To change the query, select Edit Filter, replace the default query with ORDER BY c._ts DESC, and then select Apply Filter.

    添加“ORDER BY c._ts DESC”并单击“应用筛选器”,更改默认查询

    此修改后的查询根据文档的时间戳按降序显示文档,所以现在最先列出的是第二个文档。The modified query displays the documents in descending order based on their time stamp, so now your second document is listed first.

    将查询更改为 ORDER BY c._ts DESC,然后单击“应用筛选器”

如果熟悉 SQL 语法,可以在查询谓词框中输入任何受支持的 SQL 查询If you're familiar with SQL syntax, you can enter any supported SQL queries in the query predicate box. 还可以使用数据资源管理器创建存储过程、UDF 和触发器以执行服务器端业务逻辑。You can also use Data Explorer to create stored procedures, UDFs, and triggers for server-side business logic.

数据资源管理器可以通过 Azure 门户轻松访问 API 中提供的所有内置编程数据访问功能。Data Explorer provides easy Azure portal access to all of the built-in programmatic data access features available in the APIs. 也可通过门户缩放吞吐量、获取密钥和连接字符串,以及查看 Azure Cosmos DB 帐户的指标和 SLA。You also use the portal to scale throughput, get keys and connection strings, and review metrics and SLAs for your Azure Cosmos DB account.

克隆示例应用程序Clone the sample application

现在,让我们转到如何使用代码上来。Now let's switch to working with code. 接下来,克隆 GitHub 中的 SQL API 应用程序,设置连接字符串,并运行应用程序。Let's clone a SQL API app from GitHub, set the connection string, and run it. 会看到以编程方式处理数据是多么容易。You'll see how easy it is to work with data programmatically.

运行下列命令以克隆示例存储库。Run the following command to clone the sample repository. 此命令在计算机上创建示例应用程序的副本。This command creates a copy of the sample app on your computer.

git clone https://github.com/Azure-Samples/azure-cosmos-java-getting-started.git

查看代码Review the code

此步骤是可选的。This step is optional. 如果有意了解如何使用代码创建数据库资源,可以查看以下代码片段。If you're interested in learning how the database resources are created in the code, you can review the following snippets. 否则,可以跳到运行应用Otherwise, you can skip ahead to Run the app.

使用同步 (sync) API 管理数据库资源Managing database resources using the synchronous (sync) API

  • CosmosClient 初始化。CosmosClient initialization. CosmosClient 为 Azure Cosmos 数据库服务提供客户端逻辑表示形式。The CosmosClient provides client-side logical representation for the Azure Cosmos database service. 此客户端用于对服务配置和执行请求。This client is used to configure and execute requests against the service.

    client = new CosmosClientBuilder()
        .endpoint(AccountSettings.HOST)
        .key(AccountSettings.MASTER_KEY)
        //  Setting the preferred location to Cosmos DB Account region
        //  China North is just an example. User should set preferred location to the Cosmos DB region closest to the application
        .preferredRegions(Collections.singletonList("China North"))
        .consistencyLevel(ConsistencyLevel.EVENTUAL)
        .buildClient();
    
    
  • CosmosDatabase 的创建。CosmosDatabase creation.

    CosmosDatabaseResponse cosmosDatabaseResponse = client.createDatabaseIfNotExists(databaseName);
    database = client.getDatabase(cosmosDatabaseResponse.getProperties().getId());
    
    
  • CosmosContainer 的创建。CosmosContainer creation.

    CosmosContainerProperties containerProperties =
        new CosmosContainerProperties(containerName, "/lastName");
    
    //  Create container with 400 RU/s
    CosmosContainerResponse cosmosContainerResponse =
        database.createContainerIfNotExists(containerProperties, ThroughputProperties.createManualThroughput(400));
    container = database.getContainer(cosmosContainerResponse.getProperties().getId());
    
    
  • 使用 createItem 方法创建项。Item creation by using the createItem method.

    //  Create item using container that we created using sync client
    
    //  Use lastName as partitionKey for cosmos item
    //  Using appropriate partition key improves the performance of database operations
    CosmosItemRequestOptions cosmosItemRequestOptions = new CosmosItemRequestOptions();
    CosmosItemResponse<Family> item = container.createItem(family, new PartitionKey(family.getLastName()), cosmosItemRequestOptions);
    
    
  • 使用 readItem 方法执行点读取。Point reads are performed using readItem method.

    try {
        CosmosItemResponse<Family> item = container.readItem(family.getId(), new PartitionKey(family.getLastName()), Family.class);
        double requestCharge = item.getRequestCharge();
        Duration requestLatency = item.getDuration();
        logger.info("Item successfully read with id {} with a charge of {} and within duration {}",
            item.getItem().getId(), requestCharge, requestLatency);
    } catch (CosmosException e) {
        logger.error("Read Item failed with", e);
    }
    
    
  • 使用 queryItems 方法对 JSON 执行 SQL 查询。SQL queries over JSON are performed using the queryItems method.

    // Set some common query options
    CosmosQueryRequestOptions queryOptions = new CosmosQueryRequestOptions();
    //queryOptions.setEnableCrossPartitionQuery(true); //No longer necessary in SDK v4
    //  Set query metrics enabled to get metrics around query executions
    queryOptions.setQueryMetricsEnabled(true);
    
    CosmosPagedIterable<Family> familiesPagedIterable = container.queryItems(
        "SELECT * FROM Family WHERE Family.lastName IN ('Andersen', 'Wakefield', 'Johnson')", queryOptions, Family.class);
    
    familiesPagedIterable.iterableByPage(10).forEach(cosmosItemPropertiesFeedResponse -> {
        logger.info("Got a page of query result with {} items(s) and request charge of {}",
                cosmosItemPropertiesFeedResponse.getResults().size(), cosmosItemPropertiesFeedResponse.getRequestCharge());
    
        logger.info("Item Ids {}", cosmosItemPropertiesFeedResponse
            .getResults()
            .stream()
            .map(Family::getId)
            .collect(Collectors.toList()));
    });
    
    

运行应用Run the app

现在返回到 Azure 门户,获取连接字符串信息,并使用终结点信息启动应用。Now go back to the Azure portal to get your connection string information and launch the app with your endpoint information. 这样,应用程序就可以与托管的数据库进行通信。This enables your app to communicate with your hosted database.

  1. 在 git 终端窗口中,通过 cd 转至示例代码文件夹。In the git terminal window, cd to the sample code folder.

    cd azure-cosmos-java-getting-started
    
  2. 在 git 终端窗口中,使用以下命令安装所需的 Java 包。In the git terminal window, use the following command to install the required Java packages.

    mvn package
    
  3. 在 git 终端窗口中,使用以下命令启动 Java 应用程序(请将 SYNCASYNCMODE 替换为 syncasync,具体取决于要运行的示例代码;将 YOUR_COSMOS_DB_HOSTNAME 替换为门户中带引号的 URI 值,并将 YOUR_COSMOS_DB_MASTER_KEY 替换为门户中带引号的主密钥)In the git terminal window, use the following command to start the Java application (replace SYNCASYNCMODE with sync or async depending on which sample code you would like to run, replace YOUR_COSMOS_DB_HOSTNAME with the quoted URI value from the portal, and replace YOUR_COSMOS_DB_MASTER_KEY with the quoted primary key from portal)

    mvn exec:java@SYNCASYNCMODE -DACCOUNT_HOST=YOUR_COSMOS_DB_HOSTNAME -DACCOUNT_KEY=YOUR_COSMOS_DB_MASTER_KEY
    
    

    此时,终端窗口显示通知,提示 FamilyDB 数据库已创建。The terminal window displays a notification that the FamilyDB database was created.

  4. 该应用创建名为 AzureSampleFamilyDB 的数据库The app creates database with name AzureSampleFamilyDB

  5. 该应用创建名为 FamilyContainer 的容器The app creates container with name FamilyContainer

  6. 该应用使用对象 ID 和分区键值(在本示例中为 lastName)执行点读取。The app will perform point reads using object IDs and partition key value (which is lastName in our sample).

  7. 该应用将查询项,以检索姓氏中包含 ('Andersen', 'Wakefield', 'Johnson') 的所有家庭The app will query items to retrieve all families with last name in ('Andersen', 'Wakefield', 'Johnson')

  8. 应用不删除创建的资源。The app doesn't delete the created resources. 切换回门户,以便在帐户中清理资源Switch back to the portal to clean up the resources. 以免产生费用。from your account so that you don't incur charges.

在 Azure 门户中查看 SLAReview SLAs in the Azure portal

Azure 门户监视 Cosmos DB 帐户吞吐量、存储、可用性、延迟和一致性。The Azure portal monitors your Cosmos DB account throughput, storage, availability, latency, and consistency. Azure Cosmos DB 服务级别协议 (SLA) 关联的指标的图表显示与实际性能相比的 SLA 值。Charts for metrics associated with an Azure Cosmos DB Service Level Agreement (SLA) show the SLA value compared to actual performance. 此套指标使得监视 SLA 十分透明。This suite of metrics makes monitoring your SLAs transparent.

若要查看指标和 SLA,请执行以下操作:To review metrics and SLAs:

  1. 在 Cosmos DB 帐户的导航菜单中选择“指标” 。Select Metrics in your Cosmos DB account's navigation menu.

  2. 选择一个选项卡,如“延迟” ,然后选择右侧的时间范围。Select a tab such as Latency, and select a timeframe on the right. 比较图表上的“实际” 和“SLA” 线。Compare the Actual and SLA lines on the charts.

    Azure Cosmos DB 指标套件

  3. 查看其他选项卡上的指标。Review the metrics on the other tabs.

清理资源Clean up resources

执行完应用和 Azure Cosmos DB 帐户的操作以后,可以删除所创建的 Azure 资源,以免产生更多费用。When you're done with your app and Azure Cosmos DB account, you can delete the Azure resources you created so you don't incur more charges. 若要删除资源,请执行以下操作:To delete the resources:

  1. 在 Azure 门户的“搜索”栏中,搜索并选择“资源组” 。In the Azure portal Search bar, search for and select Resource groups.

  2. 从列表中选择为本快速入门创建的资源组。From the list, select the resource group you created for this quickstart.

    选择要删除的资源组

  3. 在资源组“概览”页上,选择“删除资源组” 。On the resource group Overview page, select Delete resource group.

    删除资源组

  4. 在下一窗口中输入要删除的资源组的名称,然后选择“删除” 。In the next window, enter the name of the resource group to delete, and then select Delete.

后续步骤Next steps

在本快速入门中,你已了解了如何使用数据资源管理器创建 Azure Cosmos DB SQL API 帐户、文档数据库和容器,以及如何通过运行 Java 应用以编程方式执行同一操作。In this quickstart, you've learned how to create an Azure Cosmos DB SQL API account, create a document database and container using the Data Explorer, and run a Java app to do the same thing programmatically. 现在可以将其他数据导入 Azure Cosmos DB 帐户了。You can now import additional data into your Azure Cosmos DB account.