标签: azure-cosmosdb

找不到要包含在 CosmosDBTrigger 中的正确 nuget 包

我正在尝试开发一个 azure 函数,该函数触发集合中的插入/更新。从 azure webjobs sdk 文档中,我最好的选择是 CosmosDBTrigger 函数。但是,当我使用 Visual Studio“azure 函数”扩展创建 CosmosDBTrigger 函数时出现编译错误。看起来 CosmosDBTrigger 的 vsix 没有自动包含 CosmosDBTrigger 类的 nuget 包引用。

有没有人使用 Visual Studio 2017 创建从 ChangeFeed 项触发的 azure 函数?

更新:当我尝试引入 Microsoft.Azure.Webjobs.Extensions 时,出现以下错误。

NU1608: Detected package version outside of dependency constraint: Microsoft.NET.Sdk.Functions 1.0.11 requires Microsoft.Azure.WebJobs.Extensions (= 2.1.0) but version Microsoft.Azure.WebJobs.Extensions 3.0.0-beta5 was resolved.
NU1107: Version conflict detected for Microsoft.Azure.WebJobs. Reference the package directly from the project to resolve this issue. 
    Accelerator.Feed Microsoft.Azure.WebJobs.Extensions 3.0.0-beta5 -> Microsoft.Azure.WebJobs (>= 3.0.0-beta5) 
    Accelerator.Feed …
Run Code Online (Sandbox Code Playgroud)

database visual-studio azure-functions visual-studio-2017 azure-cosmosdb

1
推荐指数
1
解决办法
593
查看次数

如何使用 PowerShell 脚本从外部文件将数据插入 Azure Cosmos DB?

我有一个 PowerShell 脚本,用于在 Azure Cosmos DB 中创建数据库和集合,我可以使用以下 PowerShell 脚本在集合中插入一些虚拟记录。

    #region Parameters

$clientId= "< Replace with your clientId >"
$clientSecret= "< Replae with you clientsecret >"
$subscriptionName= "< Replace with your subscription name>"
$tenantId= "< Replace with your tenant Id>"
$resourceGroupName= "Demo"
$connectionString='< Replace wtih Cosmos DB Connection String >'
$cosmosDBAccounts= @('demo-account-01')
#$accountName='demo-account-01'
$databaseName='demo-db-01'
$collectionName='demo-collection-01'
$partitionkey= 'demo'

#endregion

#region Login into Azure using Interactive Mode or Service Principal details

# sign in
Write-Host "Logging in...";

#Connect-AzAccount 
$securePassword = $clientSecret | ConvertTo-SecureString …
Run Code Online (Sandbox Code Playgroud)

powershell azure azure-cosmosdb

1
推荐指数
1
解决办法
1937
查看次数

带有 CosmosDb 绑定的 Azure 函数正确的本地设置

我确定我在这里遗漏了一些简单的东西,但我无法让它发挥作用。我在本地安装了 Azure 存储模拟器,并通过 Visual Studio 2019 创建了 Azure Function 2.0。

我可以在没有 CosmosDb 绑定的情况下运行该函数,如下所示:

local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "EndpointUri": "https://localhost:8081",
    "PrimaryKey": "<KEY_HERE>"
  }
}
Run Code Online (Sandbox Code Playgroud)

Function.cs

public static class Function
{
    [FunctionName("func")]
    public static async Task Run(
        [TimerTrigger("0 * * * * *")] TimerInfo myTimer,
        ILogger log
    )
    {
        log.LogInformation($"C# Timer trigger function executed at: {DateTime.Now}");

        var endpointUri = new Uri(Environment.GetEnvironmentVariable("EndpointUri", EnvironmentVariableTarget.Process));
        var primaryKey = Environment.GetEnvironmentVariable("PrimaryKey");

        using (var client = new DocumentClient(endpointUri, primaryKey))
        {
            var queryOptions …
Run Code Online (Sandbox Code Playgroud)

c# azure azure-functions azure-cosmosdb

1
推荐指数
1
解决办法
2206
查看次数

如何在 Cosmos db .NET Core SDK V3 中访问查询“查询执行指标”

我正在对 Azure Cosmos 数据库运行查询,无论分页如何,我都需要知道检索到的文档总数。如果检索的文档数量很大,则在没有分页的情况下针对实际查询运行 Count 查询可能会非常繁重。

在下面的链接中,描述了如何访问 Cosmos db .NET SDK V2 中的查询“查询执行指标”,如果有人指导我如何使用 SDK V3 进行操作,我将不胜感激。

https://docs.microsoft.com/en-us/azure/cosmos-db/sql-api-query-metrics

.net-core azure-cosmosdb

1
推荐指数
1
解决办法
438
查看次数

错误:order by 查询没有可以从中提供服务的相应复合索引

执行以下查询时,我收到一个错误

select * from c order by c.Agent.LastStateChangeUnixTime desc,c.Priority asc

order by 查询没有相应的复合索引可以从中提供服务

我在此处此处的文档中添加了复合索引

我的综合指数错了吗?还是我错过了其他东西?

我的索引设置是:

{
    "indexingMode": "consistent",
    "automatic": true,
    "includedPaths": [
        {
            "path": "/*"
        }
    ],
    "excludedPaths": [
        {
            "path": "/\"_etag\"/?"
        }
    ],
    "compositeIndexes": [
        [
            {
                "path": "/Priority",
                "order": "descending"
            },
            {
                "path": "/Agent/LastStateChangeUnixTime",
                "order": "ascending"
            }
        ]
    ]
}
Run Code Online (Sandbox Code Playgroud)

示例对象:

{
    "Agent": {
        "TenantId": 999999,
        "PrimaryState": "Null",
        "PendingState": "Null",
        "LastStateChange": "2020-01-18T05:48:11.5397269+00:00",
        "LastStateChangeUnixTime": 1579326491,
        "Notes": null,
        "AgentId": 123,
        "id": "agent-123"
    },
    "AgentId": 123, …
Run Code Online (Sandbox Code Playgroud)

azure azure-cosmosdb azure-cosmosdb-sqlapi

1
推荐指数
1
解决办法
2193
查看次数

如何从 Cosmos DB (SQL API) 中的两个容器进行查询

我是 Cosmos db 的新手。我选择了 cosmos db(核心 sql),创建了一个包含两个容器的数据库,分别是 EmployeeContainer 和 DepartmentContainer。现在我想查询这两个容器并希望获取员工详细信息以及相关部门的详细信息。我坚持了一点,需要帮助。

下面是我的容器的结构。
EmployeeContainer : ID, Name, DepartmentID
DepartmentContainer: ID, Name

提前致谢。

azure-cosmosdb azure-cosmosdb-sqlapi

1
推荐指数
1
解决办法
4843
查看次数

如何使用属性名称中的破折号查询 Cosmos DB

问题:当属性名称中使用破折号时,使用 SQL API 查询 COSMOS DB 的正确语法是什么?

错误:查询容器预约项目失败:{"code":400,"body":{"code":"BadRequest","message":"网关无法检索查询计划:消息:{"errors":[ {"severity":"Error","location":{"start":7,"end":8},"code":"SC1001","message":"语法错误,附近的语法不正确

此查询有效 SELECT a.ID FROM accesspoint a

此查询失败 SELECT a.Point-Name FROM accesspoint a

我尝试过的:我尝试用双引号、单引号、()、<> 将值括起来

azure-cosmosdb

1
推荐指数
1
解决办法
451
查看次数

如何强制执行 cosmosDB RU 吞吐量

我有一个设置为 400 RU/s 的 cosmosGB gremlin API。如果我必须运行需要 800 个 RU 的查询,是否意味着此查询需要 2 秒才能执行?如果我将吞吐量增加到 1600 RU/s,这个查询会在半秒​​内执行吗?通过使用 RU,我没有看到查询性能有任何显着变化。

azure azure-cosmosdb azure-cosmosdb-gremlinapi

1
推荐指数
1
解决办法
193
查看次数

关于 Azure Cosmos DB 中的 CreateItemAsync 和 new PartitionKey 的困惑 - .NET Core

我正在尝试使用 Azure Cosmos DB 设置一个简单的控制台项目。我对分区键用法感到困惑。

请注意,我已经看过这个解决方案,但我相信我的情况略有不同。

我正在像这样设置容器。

private string PartitionKeyPath = "/ProductPartitionKey";
this.container = await this.database.CreateContainerIfNotExistsAsync(containerId, PartitionKeyPath);
Run Code Online (Sandbox Code Playgroud)

这是一个示例 JSON,因为它存储在容器中。所以,我成功地添加了项目。

{
    "Name": "Super Curtain",
    "UnitPrice": 500,
    "id": "124BBC08-F51C-4ED4-B961-8DD0C966F66F",
    "ProductPartitionKey": "Hello",
    "_rid": "m2VTANekt8ACAAAAAAAAAA==",
    "_self": "dbs/m2VTAA==/colls/m2VTANekt8A=/docs/m2VTANekt8ACAAAAAAAAAA==/",
    "_etag": "\"0500753f-0000-1800-0000-5f735ac70000\"",
    "_attachments": "attachments/",
    "_ts": 1601395399
}
Run Code Online (Sandbox Code Playgroud)

我可以使用以下两种用法进行插入。

var tempPartitionKey = new PartitionKey(tempProduct.ProductPartitionKey);

ItemResponse < Product > tempProductResponse = await this.container.CreateItemAsync < Product > (tempProduct, tempPartitionKey);
ItemResponse < Product > tempProductResponse = await this.container.CreateItemAsync < Product > (tempProduct);
Run Code Online (Sandbox Code Playgroud)

问题是,为什么下面的工作不起作用?

var tempPartitionKey2 = …
Run Code Online (Sandbox Code Playgroud)

azure azure-cosmosdb

1
推荐指数
1
解决办法
516
查看次数

Cosmos SDK 3 中的“未定义”#

Document DB SDK 2.# 中有一个“未定义”类,我在 Cosmos SDK 3.# 中没有看到它。请让我知道是否有等价物。如果没有,我可以用什么来替换?

谢谢,

PS,如果有任何文档描述了此类主题的操作方法,请告诉我。我发现 github 站点上的一些文档/示例非常有用,但我认为它不够全面。

https://github.com/Azure/azure-cosmos-dotnet-v3/wiki

azure-cosmosdb

1
推荐指数
1
解决办法
87
查看次数