简体   繁体   English

Azure CosmosDB PowerShell模块:未自动提升(401)

[英]Azure CosmosDB PowerShell Module: (401) not autorised

I am using the PowerShell Module "CosmosDB" ( https://www.powershellgallery.com/packages/CosmosDB ) and I repeatedly get (401) not autorized errors when I try to create collections. 我正在使用PowerShell模块“ CosmosDB”( https://www.powershellgallery.com/packages/CosmosDB ),在尝试创建集合时,反复出现(401)未授权错误。

I created a context on the account level via 我通过在帐户一级创建了上下文

New-CosmosDbContext -Account $accountName -ResourceGroup $resourceGroupName -MasterKeyType 'PrimaryMasterKey' -BackoffPolicy $backoffPolicy 

to create a database but using this context seems not to be sufficient to create a collection within the database. 创建数据库,但使用此上下文似乎不足以在数据库中创建集合。

How can I create a collection then? 那我该如何创建一个集合?

When working with CosmosDB it is important to know that if you operate on different levels in CosmosDB (account / database / collection / document) a context created on one level (eg database) is not autorized to work on another level (eg collection). 使用CosmosDB时,重要的是要知道,如果您在CosmosDB中的不同级别(帐户/数据库/馆藏/文档)上进行操作,则不会授权在一个级别(例如数据库)上创建的上下文可以在另一个级别(例如集合)上工作。 As a result it is necessary to create a context for each level. 结果,有必要为每个级别创建一个上下文。

For the problem described above it is therefore necessary to create an additional context after the database has been created via 对于上述问题,因此有必要在通过以下方式创建数据库之后创建其他上下文

New-CosmosDbContext -Account $accountName -Database $databaseName -ResourceGroup $resourceGroupName -MasterKeyType 'PrimaryMasterKey' -BackoffPolicy $backoffPolicy

This context can then be used to create a collection (see also https://github.com/PlagueHO/CosmosDB#working-with-collections ) 然后可以使用此上下文创建一个集合(另请参见https://github.com/PlagueHO/CosmosDB#working-with-collections

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM