zoukankan      html  css  js  c++  java
  • Azure Cosmos DB Core (SQL)

    • 首先要有cosmos db的account
    • 然后才可以生成cosmos db,默认throughput是4000(而且4000是最小值),自动调整从10%(即400 RU/s)开始。
      Your container throughput will automatically scale from 400 RU/s (10% of max RU/s) - 4000 RU/s based on usage.
    • 然后生成container,相当于传统数据库表的表,container共享db的throughput。

    代码生成cosmos db.

    using System;
    using System.Collections.Generic;
    using System.Collections.ObjectModel;
    using System.Linq;
    using System.Threading.Tasks;
    using Microsoft.Azure.Cosmos;
    
    namespace myApp
    {
        public class Program
        {
            private static readonly string _endpointUri = "YOUR_URI";
            private static readonly string _primaryKey = "YOUR_KEY";
            public static async Task Main(string[] args)
            {         
                using (CosmosClient client = new CosmosClient(_endpointUri, _primaryKey))
                {        
                    DatabaseResponse databaseResponse = await client.CreateDatabaseIfNotExistsAsync("Products");
                    Database targetDatabase = databaseResponse.Database;
                    await Console.Out.WriteLineAsync($"Database Id:\t{targetDatabase.Id}");
                    IndexingPolicy indexingPolicy = new IndexingPolicy
                    {
                        IndexingMode = IndexingMode.Consistent,
                        Automatic = true,
                        IncludedPaths =
                        {
                            new IncludedPath
                            {
                                Path = "/*"
                            }
                        }
                    };
                    var containerProperties = new ContainerProperties("Clothing", "/productId")
                    {
                        IndexingPolicy = indexingPolicy
                    };
                    var containerResponse = await targetDatabase.CreateContainerIfNotExistsAsync(containerProperties, 10000);
                    var customContainer = containerResponse.Container;
                    await Console.Out.WriteLineAsync($"Custom Container Id:\t{customContainer.Id}");
                }
            }
        }
    }
    
    --------------------------- 知道的更多,不知道的也更多 ---------------------------
  • 相关阅读:
    第十周博客总结
    校验码
    python-第五章习题
    python 课后习题 猜数游戏
    python 数据分析师
    python opencv图像的均值滤波、中值滤波和高斯滤波
    RPC原理及RPC实例分析
    eclipse Android创建相对布局和线性布局,主界面跳转
    python 安装opencv库的方法及图像边缘检测例子
    第三周博客总结
  • 原文地址:https://www.cnblogs.com/mryux/p/15279234.html
Copyright © 2011-2022 走看看