Azure / Azure/azure-powershell

Remove-AzCosmosDBAccount does not remove Cosmosdb for postgresql

Open
#23,035 2 comments 0 reactions 0 assignees View on GitHub
act-codegen-extensibility-squad bug CosmosDB customer-reported Service Attention
Dominant language
C#
Stars
4.8k
Forks
4.3k
Avg merge
3d 14h
Merged PRs (30d)
54

Description

### Description

When running the command `Remove-AzCosmosDBAccount -ResourceGroupName $rg -name $rn -PassThru`, the output is true, indicating the command was succesful and that the resource was removed. When double checking, however, that is not the case.

1) Run the command and get response `True` - would assume the resource was deleted
![image](https://github.com/Azure/azure-powershell/assets/38536164/c9769b4f-657c-4da1-94b7-5fb42fd73241)

2) Still visible in Azure Portal
![image](https://github.com/Azure/azure-powershell/assets/38536164/0d133790-cb00-49b7-9687-2755531e274d)

3) And still accessible via pgAdmin
![image](https://github.com/Azure/azure-powershell/assets/38536164/86f8d39b-a4c3-4938-a069-3a9f08e4706e)

### Issue script & Debug output

```PowerShell
DEBUG: 23:41:44 - RemoveAzCosmosDBAccount begin processing with ParameterSet 'ByNameParameterSet'.
DEBUG: 23:41:44 - using account id 'myemailisredacted@company'...
DEBUG: 23:41:44 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: [Common.Authentication]: Authenticating using Account: 'myemailisredacted@company', environment: 'AzureCloud', tenant: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
DEBUG: 23:41:44 - [ConfigManager] Got nothing from [EnableLoginByWam], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: 23:41:44 - [SilentAuthenticator] Calling SharedTokenCacheCredential.GetTokenAsync - TenantId:'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', Scopes:'https://management.core.windows.net//.default', AuthorityHost:'https://login.microsoftonline.com/', UserId:'myemailisredacted@company'
DEBUG: SharedTokenCacheCredential.GetToken invoked. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId:
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 2d1a1c31-c40b-4de1-97da-efb509862f30] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 2d1a1c31-c40b-4de1-97da-efb509862f30] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 2d1a1c31-c40b-4de1-97da-efb509862f30] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 2d1a1c31-c40b-4de1-97da-efb509862f30] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 2d1a1c31-c40b-4de1-97da-efb509862f30] IsLegacyAdalCacheEnabled: yes
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z] Found 1 cache accounts and 0 broker accounts
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z] Returning 1 accounts
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953] MSAL MSAL.NetCore with assembly version '4.49.1.0'. CorrelationId(62d3fb89-b2ea-47ce-a104-f99246d2f953)
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953] === AcquireTokenSilent Parameters ===
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953] LoginHint provided: False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953] Account provided: True
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953] ForceRefresh: False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953]
=== Request Data ===
Authority Provided? - True
Scopes - https://management.core.windows.net//.default
Extra Query Params Keys (space separated) -
ApiId - AcquireTokenSilent
IsConfidentialClient - False
SendX5C - False
LoginHint ? False
IsBrokerConfigured - False
HomeAccountId - False
CorrelationId - 62d3fb89-b2ea-47ce-a104-f99246d2f953
UserAssertion set: False
LongRunningOboCacheKey set: False
Region configured:

DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953] === Token Acquisition (SilentRequest) started:
Scopes: https://management.core.windows.net//.default
Authority Host: login.microsoftonline.com
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953] Access token is not expired. Returning the found cache entry. [Current time (10/20/2023 21:41:44) - Expiration Time (10/20/2023 22:53:18 +00:00) - Extended Expiration Time (10/20/2023 22:53:18 +00:00)]
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953] Returning access token found in cache. RefreshOn exists ? False
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953] [Region discovery] Not using a regional authority.
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953]
=== Token Acquisition finished successfully:
DEBUG: False MSAL 4.49.1.0 MSAL.NetCore .NET 7.0.11 Microsoft Windows 10.0.22631 [2023-10-20 21:41:44Z - 62d3fb89-b2ea-47ce-a104-f99246d2f953] AT expiration time: 2023-10-20 22:53:18 +00:00, scopes: https://management.core.windows.net//user_impersonation https://management.core.windows.net//.default. source: Cache
DEBUG: SharedTokenCacheCredential.GetToken succeeded. Scopes: [ https://management.core.windows.net//.default ] ParentRequestId: ExpiresOn: 2023-10-20T22:53:18.0000000+00:00
DEBUG: [Common.Authentication]: Received token with LoginType 'User', Tenant: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx', UserId: 'myemailisredacted@company'
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
DELETE

Absolute Uri:
https://management.azure.com/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/nl-lab/providers/Microsoft.DocumentDB/databaseAccounts/swyft-nl-dev?api-version=2023-04-15

Headers:
Accept-Language : en-US
x-ms-client-request-id : 5400b36f-d7e5-4863-88a6-90e9bfe7d88a

Body:

DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
NoContent

Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-ratelimit-remaining-subscription-deletes: 14998
x-ms-request-id : 9ff5bce3-940f-4118-9dff-4e78f27818d9
x-ms-correlation-request-id : 9ff5bce3-940f-4118-9dff-4e78f27818d9
x-ms-routing-request-id : SWEDENSOUTH:20231020T214142Z:9ff5bce3-940f-4118-9dff-4e78f27818d9
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
Date : Fri, 20 Oct 2023 21:41:42 GMT

Body:

True
DEBUG: 23:41:44 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 23:41:44 - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: AzureQoSEvent: Module: Az.CosmosDB:1.12.0; CommandName: Remove-AzCosmosDBAccount; PSVersion: 7.3.8; IsSuccess: True; Duration: 00:00:00.2914476
DEBUG: 23:41:44 - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 23:41:44 - RemoveAzCosmosDBAccount end processing.
```

### Environment data

```PowerShell
Name Value
---- -----
PSVersion 7.3.8
PSEdition Core
GitCommitId 7.3.8
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
```

### Module versions

```PowerShell
ModuleType Version PreRelease Name ExportedCommands
---------- ------- ---------- ---- ----------------
Script 2.13.1 Az.Accounts {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script 1.12.0 Az.CosmosDB {Get-AzCosmosDBAccount, Get-AzCosmosDBAccountKey, Get-AzCosmosDBCassandraKeyspace, Get-AzCosmosDBCassandraKeyspaceThroughput…}
```

### Error output

```PowerShell
DEBUG: 23:53:02 - ResolveError begin processing with ParameterSet 'AnyErrorParameterSet'.
DEBUG: 23:53:02 - using account id 'myemailisredacted@company'...
DEBUG: 23:53:02 - [ConfigManager] Got nothing from [DisplayBreakingChangeWarning], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 23:53:02 - [ConfigManager] Got nothing from [DisplayRegionIdentified], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 23:53:02 - [ConfigManager] Got nothing from [CheckForUpgrade], Module = [], Cmdlet = []. Returning default value [False].
DEBUG: AzureQoSEvent: Module: Az.Accounts:2.13.1; CommandName: Resolve-AzError; PSVersion: 7.3.8; IsSuccess: True; Duration: 00:00:00.0009135
DEBUG: 23:53:02 - [ConfigManager] Got nothing from [EnableDataCollection], Module = [], Cmdlet = []. Returning default value [True].
DEBUG: 23:53:02 - ResolveError end processing.
```

Contributor guide

Open the contributing guide

Research direction

Start with the Remove-AzCosmosDBAccount entry point in Az.CosmosDB 1.12.0 and reproduce the command against a Cosmos DB for PostgreSQL account. Compare the successful DELETE request and True result with the resource's continued presence in Azure Portal and pgAdmin. Done means the command removes the account or accurately reports the deletion failure.

Written by the indexing model from the issue text.

Assessment

Tech stack
azure, postgresql, powershell
Domain
cli, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.