Skip to content
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-AzPostgreSqlServer module issues #19273

Closed
DevonK3 opened this issue Aug 19, 2022 · 10 comments
Closed

Get-AzPostgreSqlServer module issues #19273

DevonK3 opened this issue Aug 19, 2022 · 10 comments
Labels
customer-reported PostgreSQL question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.

Comments

@DevonK3
Copy link

DevonK3 commented Aug 19, 2022

Description

When running Get-AzPostgreSqlServer, it should return all of the Postgres SQL server names. When I run it in one subscription, it works. But when I run it against my Prod subscription, it doesn't return anything, even though they both have servers in them. Even if I use the optional -Subscription parameter, it doesn't work.

Issue script & Debug output

PS> Get-AzPostgreSqlServer -SubscriptionId <NonProd SubId>
Name               Location AdministratorLogin Version StorageProfileStorageMb SkuName   SkuTier        SslEnforcement
----               -------- ------------------ ------- ----------------------- -------   -------        --------------
banrmprcarlflpgsql eastus   airflow_admin      11      102400                  GP_Gen5_4 GeneralPurpose Enabled
banorionairflowdb  eastus   azureadmin         11      102400                  GP_Gen5_2 GeneralPurpose Enabled

===================

PS> Get-AzPostgreSqlServer -SubscriptionId <Prod SubId>
PS> 

====================
For the same Prod Subscription ...

PS> Get-AzPostgreSqlConfiguration -ServerName baporionairflowdb -ResourceGroupName <rgname>
Name                                  Value                      AllowedValue
----                                  -----                      ------------
array_nulls                           on                         on,off
backslash_quote                       safe_encoding              safe_encoding,on,off
bytea_output                          hex                        escape,hex
check_function_bodies                 on                         on,off
(redacted)

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Darwin 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.9.1                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script     1.1.0                 Az.PostgreSql                       {Get-AzPostgreSqlConfiguration, Get-AzPostgreSqlConnectionString, Get-AzPostgreSqlFirewallRule, Get-AzPo…
Script     4.2.0                 Az.Resources                        {Add-AzADGroupMember, Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzADAppCredential…}

Error output

WARNING: Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release.  Please change any scripts that use this alias to use `Resolve-AzError` instead.
Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.

   HistoryId: 28

Message        : The term 'Get-AzModule' is not recognized as a name of a cmdlet, function, script file, or executable program.
                 Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
StackTrace     :    at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions
                 searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
                    at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)
                    at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)
                    at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
                    at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
                    at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst,
                 CommandRedirection[] redirections, ExecutionContext context)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[]
                 pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.CommandNotFoundException
InvocationInfo : {}
Line           : Get-AzModule Az*
Position       : At line:1 char:1
                 + Get-AzModule Az*
                 + ~~~~~~~~~~~~
HistoryId      : 28


   HistoryId: -1

Message        : Method invocation failed because [Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Models.Api20171201.Configuration] does not contain a method named 'Sort'.
StackTrace     :    at System.Management.Automation.EnumerableOps.MethodInvokerWorker(CallSite invokeMemberSite, IEnumerator enumerator, Object[] args, ExecutionContext
                 context, List`1 result, Boolean& foundMethod)
                    at System.Management.Automation.EnumerableOps.MethodInvoker(PSInvokeMemberBinder binder, Type delegateType, IEnumerator enumerator, Object[] args, Type
                 typeForMessage)
                    at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
                    at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.RuntimeException
InvocationInfo : {}
Line           : $sqcf.Sort()
Position       : At line:1 char:1
                 + $sqcf.Sort()
                 + ~~~~~~~~~~~~
HistoryId      : -1


The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.
@DevonK3 DevonK3 added bug This issue requires a change to an existing behavior in the product in order to be resolved. needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Aug 19, 2022
@ghost ghost added customer-reported and removed needs-triage This is a new issue that needs to be triaged to the appropriate team. labels Aug 19, 2022
@dingmeng-xue dingmeng-xue added PostgreSQL question The issue doesn't require a change to the product in order to be resolved. Most issues start as that and removed bug This issue requires a change to an existing behavior in the product in order to be resolved. labels Aug 22, 2022
@dingmeng-xue
Copy link
Member

@DevonK3 could you double check that current account has permission to access that subscription? You can turn on debug message $DebugPreference = "Continue" and execute cmdlet again. You can see whether the request is sent to target subscription. If no, please share us error. Otherwise, it may relate to permission. You also can login that sub at first and then execute Get-AzPostgreSqlServer using default subscription.

@DevonK3
Copy link
Author

DevonK3 commented Aug 22, 2022

Yes. I am the Subscription Owner. I also verified my other Subscription Owner had the same issue.

@DevonK3
Copy link
Author

DevonK3 commented Aug 22, 2022

PS /Users/devonkelly> Get-AzPostgreSqlServer
PS /Users/devonkelly> $DebugPreference = "Continue"
PS /Users/devonkelly> Get-AzPostgreSqlServer
DEBUG: 10:34:56 AM - GetAzureRMContextCommand end processing.
DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:
DEBUG: [CmdletProcessRecordAsyncStart]: Created new QosEvent for command 'Get-AzPostgreSqlServer_List1'
DEBUG: CmdletProcessRecordAsyncStart:
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: /subscriptions/[redacted]/providers/Microsoft.DBforPostgreSQL/servers?api-version=2017-12-01
DEBUG: RequestCreated: /subscriptions/[redacted]/providers/Microsoft.DBforPostgreSQL/servers?api-version=2017-12-01
DEBUG: HeaderParametersAdded:
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/[redacted]/providers/Microsoft.DBforPostgreSQL/servers?api-version=2017-12-01

Headers:
x-ms-unique-id : 2
x-ms-client-request-id : 93c29171-a6bf-4fc8-a55c-f156a2715ad7
CommandName : Get-AzPostgreSqlServer
FullCommandName : Get-AzPostgreSqlServer_List1
ParameterSetName : __AllParameterSets
User-Agent : AzurePowershell/v0.0.0,Az.PostgreSql/1.1.0

Body:

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

Status Code:
OK

Headers:
Cache-Control : no-cache
Pragma : no-cache
x-ms-ratelimit-remaining-subscription-reads: 11994
x-ms-request-id : d5c93891-309c-4571-abf2-c894007882fa
x-ms-correlation-request-id : d5c93891-309c-4571-abf2-c894007882fa
x-ms-routing-request-id : SOUTHCENTRALUS:20220822T153456Z:d5c93891-309c-4571-abf2-c894007882fa
Strict-Transport-Security : max-age=31536000; includeSubDomains
X-Content-Type-Options : nosniff
Date : Mon, 22 Aug 2022 15:34:56 GMT

Body:
{
"value": []
}

DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:
DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: AzureQoSEvent: Module: Az.PostgreSql:1.1.0; CommandName: Get-AzPostgreSqlServer_List1; PSVersion: ; IsSuccess: True; Duration: 00:00:00
DEBUG: Finish sending metric.
DEBUG: CmdletEndProcessing:
PS /Users/devonkelly> get-azcontext

Name Account SubscriptionName Environment TenantId


aa-ba-prod-spoke [redactedp aa-ba-prod-spoke AzureCloud [redacted]
DEBUG: 10:35:43 AM - GetAzureRMContextCommand end processing.

@dingmeng-xue
Copy link
Member

@DevonK3 you also can use Get-AzResource to detect your resource. Example 3 or 4 tells you how to fetch resource by its name or group name. If you can see your resource there, please double check its resource type. There are 2 types of PostgreSQL, single server or flexible server. Get-AzPostgreSqlServer only covers former one.

@DevonK3
Copy link
Author

DevonK3 commented Aug 23, 2022

Correct. But to use Get-AzResource I would need to know the Name and ResourceGroupName. I'm trying to get all PSQL instances in my Subscription to use in a loop to validate SCCF settings. It works in my NonProd subscription, but not in my Prod subscription. We cannot understand why.

> Get-AzPostgreSqlServer
>
> Get-AzResource -ResourceGroupName ba-p-zeaus-airflow-rg -Name baporionairflowdb

Name              : baporionairflowdb
ResourceGroupName : ba-p-zeaus-airflow-rg
ResourceType      : Microsoft.DBforPostgreSQL/servers
Location          : eastus

@dingmeng-xue
Copy link
Member

dingmeng-xue commented Aug 24, 2022

@DevonK3 , Let me involve PostgreSQL team.

@dingmeng-xue dingmeng-xue added the Service Attention This issue is responsible by Azure service team. label Aug 24, 2022
@ghost
Copy link

ghost commented Aug 24, 2022

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @sunilagarwal, @lfittl-msft, @sr-msft, @niklarin.

Issue Details

Description

When running Get-AzPostgreSqlServer, it should return all of the Postgres SQL server names. When I run it in one subscription, it works. But when I run it against my Prod subscription, it doesn't return anything, even though they both have servers in them. Even if I use the optional -Subscription parameter, it doesn't work.

Issue script & Debug output

PS> Get-AzPostgreSqlServer -SubscriptionId <NonProd SubId>
Name               Location AdministratorLogin Version StorageProfileStorageMb SkuName   SkuTier        SslEnforcement
----               -------- ------------------ ------- ----------------------- -------   -------        --------------
banrmprcarlflpgsql eastus   airflow_admin      11      102400                  GP_Gen5_4 GeneralPurpose Enabled
banorionairflowdb  eastus   azureadmin         11      102400                  GP_Gen5_2 GeneralPurpose Enabled

===================

PS> Get-AzPostgreSqlServer -SubscriptionId <Prod SubId>
PS> 

====================
For the same Prod Subscription ...

PS> Get-AzPostgreSqlConfiguration -ServerName baporionairflowdb -ResourceGroupName <rgname>
Name                                  Value                      AllowedValue
----                                  -----                      ------------
array_nulls                           on                         on,off
backslash_quote                       safe_encoding              safe_encoding,on,off
bytea_output                          hex                        escape,hex
check_function_bodies                 on                         on,off
(redacted)

Environment data

Name                           Value
----                           -----
PSVersion                      7.2.6
PSEdition                      Core
GitCommitId                    7.2.6
OS                             Darwin 21.6.0 Darwin Kernel Version 21.6.0: Wed Aug 10 14:25:27 PDT 2022; root:xnu-8020.141.5~2/RELEASE_X86_64
Platform                       Unix
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Module versions

ModuleType Version    PreRelease Name                                ExportedCommands
---------- -------    ---------- ----                                ----------------
Script     2.9.1                 Az.Accounts                         {Add-AzEnvironment, Clear-AzConfig, Clear-AzContext, Clear-AzDefault…}
Script     1.1.0                 Az.PostgreSql                       {Get-AzPostgreSqlConfiguration, Get-AzPostgreSqlConnectionString, Get-AzPostgreSqlFirewallRule, Get-AzPo…
Script     4.2.0                 Az.Resources                        {Add-AzADGroupMember, Export-AzResourceGroup, Export-AzTemplateSpec, Get-AzADAppCredential…}

Error output

WARNING: Upcoming breaking changes in the cmdlet 'Resolve-AzError' :
The `Resolve-Error` alias will be removed in a future release.  Please change any scripts that use this alias to use `Resolve-AzError` instead.
Note : Go to https://aka.ms/azps-changewarnings for steps to suppress this breaking change warning, and other information on breaking changes in Azure PowerShell.

   HistoryId: 28

Message        : The term 'Get-AzModule' is not recognized as a name of a cmdlet, function, script file, or executable program.
                 Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
StackTrace     :    at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandTypes commandTypes, SearchResolutionOptions
                 searchResolutionOptions, CommandOrigin commandOrigin, ExecutionContext context)
                    at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin, ExecutionContext context)
                    at System.Management.Automation.CommandDiscovery.LookupCommandInfo(String commandName, CommandOrigin commandOrigin)
                    at System.Management.Automation.CommandDiscovery.LookupCommandProcessor(String commandName, CommandOrigin commandOrigin, Nullable`1 useLocalScope)
                    at System.Management.Automation.ExecutionContext.CreateCommand(String command, Boolean dotSource)
                    at System.Management.Automation.PipelineOps.AddCommand(PipelineProcessor pipe, CommandParameterInternal[] commandElements, CommandBaseAst commandBaseAst,
                 CommandRedirection[] redirections, ExecutionContext context)
                    at System.Management.Automation.PipelineOps.InvokePipeline(Object input, Boolean ignoreInput, CommandParameterInternal[][] pipeElements, CommandBaseAst[]
                 pipeElementAsts, CommandRedirection[][] commandRedirections, FunctionContext funcContext)
                    at System.Management.Automation.Interpreter.ActionCallInstruction`6.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.CommandNotFoundException
InvocationInfo : {}
Line           : Get-AzModule Az*
Position       : At line:1 char:1
                 + Get-AzModule Az*
                 + ~~~~~~~~~~~~
HistoryId      : 28


   HistoryId: -1

Message        : Method invocation failed because [Microsoft.Azure.PowerShell.Cmdlets.PostgreSql.Models.Api20171201.Configuration] does not contain a method named 'Sort'.
StackTrace     :    at System.Management.Automation.EnumerableOps.MethodInvokerWorker(CallSite invokeMemberSite, IEnumerator enumerator, Object[] args, ExecutionContext
                 context, List`1 result, Boolean& foundMethod)
                    at System.Management.Automation.EnumerableOps.MethodInvoker(PSInvokeMemberBinder binder, Type delegateType, IEnumerator enumerator, Object[] args, Type
                 typeForMessage)
                    at System.Dynamic.UpdateDelegates.UpdateAndExecute1[T0,TRet](CallSite site, T0 arg0)
                    at System.Management.Automation.Interpreter.DynamicInstruction`2.Run(InterpretedFrame frame)
                    at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
Exception      : System.Management.Automation.RuntimeException
InvocationInfo : {}
Line           : $sqcf.Sort()
Position       : At line:1 char:1
                 + $sqcf.Sort()
                 + ~~~~~~~~~~~~
HistoryId      : -1


The Azure PowerShell team is listening, please let us know how we are doing: https://aka.ms/azpssurvey?Q_CHL=ERROR.
Author: DevonK3
Assignees: -
Labels:

PostgreSQL, Service Attention, question, customer-reported

Milestone: -

@nachoalonsoportillo
Copy link

@DevonK3 Thanks for reporting this issue. Can you please check if this still happens with v12.0.0?

@DevonK3
Copy link
Author

DevonK3 commented Jun 24, 2024

Confirmed. Get-AzPostgreSqlServer shows all "Azure Database for PostgreSQL single server" instances in both Subscriptions.

@DevonK3 DevonK3 closed this as completed Jun 24, 2024
@DevonK3
Copy link
Author

DevonK3 commented Jun 24, 2024

12.0.0 Az
azure-cli 2.61.0
PowerShell 7.4.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported PostgreSQL question The issue doesn't require a change to the product in order to be resolved. Most issues start as that Service Attention This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests

3 participants