-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get-AzCosmosDBSqlContainer errors with null ref when run on a container that does not have a unique key policy. It runs as expected when run on a container that does have a unique key policy. #11381
Comments
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @kushagraThapar, @srinathnarayanan, @southpolesteve, @shurd. |
Targeting S168. |
Any update on this issue? |
Please expect this to be resolved in the upcoming version of Az.CosmosDB 0.1.4 |
@MehaKaushik |
I do face the same problem, Is there any Quick hack for us to proceed until you release 0.1.4? |
The ETA for the 0.1.4 is around two weeks from now. For the time being you can use this cmdlet: https://docs.microsoft.com/en-us/powershell/module/az.resources/get-azresource?view=azps-3.7.0 |
@karthick3d @SafwanHussain To expand on @MehaKaushik's suggestion to use Get-AzResource, here is a full implementation that both lists containers in a database, as well as retrieves a specified one. (Github Markdown renders the following snippet strangely but just copy-paste into your Powershell editor and it should be fine.) ---------------------------------------------------Replace "my***Name" with your own values$resourceGroupName = "myResourceGroupName" ---------------------------------------------------$apiVersion = "2020-03-01" ---------------------------------------------------Write-Host "List containers in the database" Write-Host "Show specified container" --------------------------------------------------- |
Thank you @plzm and @MehaKaushik . It worked for me that saved few days of blocker :). |
Root Cause: The issue reproduces on Containers created using Portal, the containers created using Portal do not have an empty UniqueKeyPolicy object, which is the case for containers created using mangement sdk(consumed by powershell). The issue was not reproducible for containers created using Powershell/Mangement SDK. |
Hey @karthick3d @SafwanHussain Az.CosmosDB 0.1.4 is released https://www.powershellgallery.com/packages/Az.CosmosDB/0.1.4 Please verify that the issue is resolved. |
@MehaKaushik When using Az.CosmosDB version 0.1.4 I have found the issue remains.
|
@tylersplitt Do you mind sharing the details of the container, for further debugging. |
Here are the debug logs (sanitized)
|
@tylersplitt please verify if your issue is resolved in the latest version 0.1.5 |
Closing, since the fix was checked in and released in version 0.1.5 |
Example on a SQL API account with one region, no multi-master, one database without provisioned throughput, one container with provisioned throughput
$container = Get-AzCosmosDBSqlContainer -ResourceGroupName myResourceGroup -AccountName pz-cdb-sql -DatabaseName myDatabase -Name myContainer
Yields
Get-AzCosmosDBSqlContainer: Object reference not set to an instance of an object.
Running above cmdlet with -Debug yields
$container = Get-AzCosmosDBSqlContainer -ResourceGroupName myResourceGroup -AccountName pz-cdb-sql -DatabaseName myDatabase -Name myContainer -Debug
DEBUG: 11:56:58 AM - GetAzCosmosDBSqlContainer begin processing with ParameterSet 'ByNameParameterSet'.
DEBUG: 11:56:58 AM - using account id 'paelaz@microsoft.com'...
DEBUG: [Common.Authentication]: Authenticating using Account: 'paelaz@microsoft.com', environment: 'AzureCloud', tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47'
DEBUG: [Common.Authentication]: Authenticating using configuration values: Domain: '72f988bf-86f1-41af-91ab-2d7cd011db47', Endpoint: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirect: 'urn:ietf:wg:oauth:2.0:oob', ResourceClientUri: 'https://management.core.windows.net/', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using context with Authority 'https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/', CorrelationId: '00000000-0000-0000-0000-000000000000', ValidateAuthority: 'True'
DEBUG: [Common.Authentication]: Acquiring token using AdalConfiguration with Domain: '72f988bf-86f1-41af-91ab-2d7cd011db47', AdEndpoint: 'https://login.microsoftonline.com/', ClientId: '1950a258-227b-4e31-a9cf-717495945fc2', ClientRedirectUri: urn:ietf:wg:oauth:2.0:oob
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3734859Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: ADAL PCL.CoreCLR with assembly version '3.19.2.6005', file version '3.19.50302.0130' and informational version '2a8bec6c4c76d0c1ef819b55bdc3cda2d2605056' is running...
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3736516Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: ADAL PCL.CoreCLR with assembly version '3.19.2.6005', file version '3.19.50302.0130' and informational version '2a8bec6c4c76d0c1ef819b55bdc3cda2d2605056' is running...
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3738340Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: === Token Acquisition started:
CacheType: null
Authentication Target: User
, Authority Host: login.microsoftonline.com
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3739524Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: === Token Acquisition started:
Authority: https://login.microsoftonline.com/72f988bf-86f1-41af-91ab-2d7cd011db47/
Resource: https://management.core.windows.net/
ClientId: 1950a258-227b-4e31-a9cf-717495945fc2
CacheType: null
Authentication Target: User
DEBUG: [ADAL]: Verbose: 2020-03-20T15:56:58.3740906Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: Loading from cache.
DEBUG: [ADAL]: Verbose: 2020-03-20T15:56:58.3741639Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: Loading from cache.
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3851779Z: 00000000-0000-0000-0000-000000000000 - LoggerBase.cs: Deserialized 5 items to token cache.
DEBUG: [ADAL]: Verbose: 2020-03-20T15:56:58.3853854Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: Looking up cache for a token...
DEBUG: [ADAL]: Verbose: 2020-03-20T15:56:58.3855073Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: Looking up cache for a token...
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3856271Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: An item matching the requested resource was found in the cache
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3857346Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: An item matching the requested resource was found in the cache
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3858890Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: 12.641452061666667 minutes left until token in cache expires
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3860021Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: 12.641452061666667 minutes left until token in cache expires
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3860982Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: A matching item (access token or refresh token or both) was found in the cache
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3862408Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: A matching item (access token or refresh token or both) was found in the cache
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3865247Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: === Token Acquisition finished successfully. An access token was returned: Expiration Time: 3/20/2020 4:09:36 PM +00:00
DEBUG: [ADAL]: Information: 2020-03-20T15:56:58.3866493Z: 099927c1-0db7-4795-aaff-e92e16bca26c - LoggerBase.cs: === Token Acquisition finished successfully. An access token was returned: Expiration Time: 3/20/2020 4:09:36 PM +00:00Access Token Hash: nu4rcrobCYI9iQ2u26Ik5hYG+UIxAi098uDzPtosB6o=
User id: b995e2c1-f7d9-41c8-a865-c5a7213150b8
DEBUG: [Common.Authentication]: Renewing Token with Type: 'Bearer', Expiry: '03/20/2020 16:09:36 +00:00', MultipleResource? 'True', Tenant: '72f988bf-86f1-41af-91ab-2d7cd011db47', UserId: 'paelaz@microsoft.com'
DEBUG: [Common.Authentication]: User info for token DisplayId: 'paelaz@microsoft.com', Name: Patrick El-Azem, IdProvider: 'https://sts.windows.net/72f988bf-86f1-41af-91ab-2d7cd011db47/', Uid: 'b995e2c1-f7d9-41c8-a865-c5a7213150b8'
DEBUG: [Common.Authentication]: Checking token expiration, token expires '03/20/2020 16:09:36 +00:00' Comparing to '03/20/2020 15:56:58 +00:00' With threshold '00:05:00', calculated time until token expiry: '00:12:38.4853907'
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method:
GET
Absolute Uri:
https://management.azure.com/subscriptions/e61e4c75-268b-4c94-ad48-237aa3231481/resourceGroups/myResourceGroup/providers/Microsoft.DocumentDB/databaseAccounts/pz-cdb-sql/sqlDatabases/myDatabase/containers/myContainer?api-version=2019-08-01
Headers:
x-ms-client-request-id : c6369217-6854-4ddd-95bc-cf452aee25ba
Accept-Language : en-US
Body:
DEBUG: ============================ HTTP RESPONSE ============================
Status Code:
OK
Headers:
Cache-Control : no-store, no-cache
Pragma : no-cache
Strict-Transport-Security : max-age=31536000; includeSubDomains
x-ms-gatewayversion : version=2.10.0
Server : Microsoft-HTTPAPI/2.0
x-ms-ratelimit-remaining-subscription-reads: 11988
x-ms-request-id : a91b54a8-d7f1-4932-b5c6-991c6e1ad39d
x-ms-correlation-request-id : a91b54a8-d7f1-4932-b5c6-991c6e1ad39d
x-ms-routing-request-id : CANADACENTRAL:20200320T155658Z:a91b54a8-d7f1-4932-b5c6-991c6e1ad39d
X-Content-Type-Options : nosniff
Date : Fri, 20 Mar 2020 15:56:57 GMT
Body:
{
"id": "/subscriptions/e61e4c75-268b-4c94-ad48-237aa3231481/resourceGroups/myResourceGroup/providers/Microsoft.DocumentDB/databaseAccounts/pz-cdb-sql/sqlDatabases/myDatabase/containers/myContainer",
"type": "Microsoft.DocumentDB/databaseAccounts/sqlDatabases/containers",
"name": "myContainer",
"properties": {
"resource": {
"id": "myContainer",
"indexingPolicy": {
"indexingMode": "consistent",
"automatic": true,
"includedPaths": [
{
"path": "/*"
}
],
"excludedPaths": [
{
"path": "/"_etag"/?"
}
]
},
"partitionKey": {
"paths": [
"/id"
],
"kind": "Hash"
},
"conflictResolutionPolicy": {
"mode": "LastWriterWins",
"conflictResolutionPath": "/_ts",
"conflictResolutionProcedure": ""
},
"geospatialConfig": {
"type": "Geography"
},
"_rid": "Rv1HAITyZjc=",
"_ts": 1584714083,
"_self": "dbs/Rv1HAA==/colls/Rv1HAITyZjc=/",
"_etag": ""0000cc0a-0000-0100-0000-5e74d1630000"",
"_docs": "docs/",
"_sprocs": "sprocs/",
"_triggers": "triggers/",
"_udfs": "udfs/",
"_conflicts": "conflicts/",
"statistics": [
{
"id": "0",
"sizeInKB": 0,
"documentCount": 0,
"partitionKeys": []
}
]
}
}
}
Get-AzCosmosDBSqlContainer: Object reference not set to an instance of an object.
DEBUG: AzureQoSEvent: CommandName - Get-AzCosmosDBSqlContainer; IsSuccess - False; Duration - 00:00:00.6874740;; Exception - System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.Azure.Commands.CosmosDB.Models.PSUniqueKeyPolicy..ctor(UniqueKeyPolicy uniqueKey)
at Microsoft.Azure.Commands.CosmosDB.Models.PSSqlContainerGetPropertiesResource..ctor(SqlContainerGetPropertiesResource sqlContainerGetPropertiesResource)
at Microsoft.Azure.Commands.CosmosDB.Models.PSSqlContainerGetResults..ctor(SqlContainerGetResults sqlContainerGetResults)
at Microsoft.Azure.Commands.CosmosDB.GetAzCosmosDBSqlContainer.ExecuteCmdlet()
at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 11:56:59 AM - GetAzCosmosDBSqlContainer end processing.
The text was updated successfully, but these errors were encountered: