【发布时间】:2022-07-22 16:35:12
【问题描述】:
源代码:
$resourceGroupName = 'rg-****'
$accountName = 'cosmosserver-****'
$databaseName = 'DefaultSystemDB'
$OrganisationName = "SampleOrg"
$ContractName = 'SampleContract'
$TypeName = 'SampleType"
$currentDate = Get-Date -Format 'yyyy-MM-dd HH:mm:ss
write-Host $currentDate
$containerName = 'Organisation'
$partitionKey = '/id'
$cosmosDbContext = New-CosmosDbContext -Account $accountName -Database $databaseName -ResourceGroup $resourceGroupName
$Organisationid='$([Guid]::NewGuid().ToString())'
write-Host Organisationid: $Organisationid
$document = @"
{
"Name": '$OrganisationName',
"CreatedOn": '$currentDate',
"id": '$Organisationid'
}
"@
$partitionkey = '$Organisationid'
New-CosmosDbDocument -Context $cosmosDbContext -CollectionId $containerName -DocumentBody $document -PartitionKey $partitionkey
问题:
我在 azuredevops 的 azureCLI 任务中执行上述代码时收到以下错误 错误: New-CosmosDbContext : 术语“New-CosmosDbContext”未被识别为 cmdlet 的名称,
解决此问题或使用 AzureDevops 中的 azure CLI 任务在 cosmosDB 容器中插入文档的任何其他建议的步骤是什么?请帮我找出这个问题。
【问题讨论】:
标签: azure-devops