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 an empty list of firewallRules when querying a postgres instance through a AzureFunction #21589

Closed
2 of 6 tasks
blured75 opened this issue Apr 25, 2022 · 5 comments
Closed
2 of 6 tasks
Assignees
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-author-feedback Workflow: More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@blured75
Copy link

  • Package Name: @azure/arm-postgresql
  • Package Version: 6.0.0
  • Operating system: MacOS
  • nodejs
    • version: v14.18.3
  • browser
    • name/version:
  • typescript
    • version: 4.4.2
  • Is the bug related to documentation in

Describe the bug
I'm trying to get the list of firewall rules on a Postgres Instance in Azure, using the azure-js-sdk. Locally it works like a charm, I've got the list of firewall rules from my selected postgres instance. When I launch this process in an Azure function, targetting the same postgres instance, the firewall rules list is always empty, and there is no error message or exception thrown.

To Reproduce
Steps to reproduce the behavior:
Code which work locally

  ...
   const azureCredential = new DefaultAzureCredential();
   const subscriptionClient = new SubscriptionClient(azureCredential);
   const postgresCli = new PostgreSQLManagementClient(azureCredential, 'mySubscriptionId');
   const fwRules = postgresCli.firewallRules.listByServer('myResourceGroup', 'myServerName');

   for await (const fwRule of fwRules) {
      context.log.info('in the for of fwRules');
      context.log.info('DELETING ', fwRule.name, ' in ', azResourceGroup);
      ...
   }

Code which return a empty firewall rules list in a Azure function

index.ts

const httpTrigger: AzureFunction = async function (context: Context, req: HttpRequest): Promise~void~ {
    try {
      const azureCredential = new DefaultAzureCredential();
      const subscriptionClient = new SubscriptionClient(azureCredential);
      const postgresCli = new PostgreSQLManagementClient(azureCredential, 'mySubscriptionId');
      const fwRules = postgresCli.firewallRules.listByServer('myResourceGroup', 'myServerName');

      for await (const fwRule of fwRules) {
         context.log.info('in the for of fwRules');
         context.log.info('DELETING ', fwRule.name, ' in ', azResourceGroup);
         ...
      }
    }
    catch (e) {
        context.log.error(e);
        context.res = { status: 500, body: 'Internal Server Error' };
    }
};
function.json

    'bindings': [
    {
      'authLevel': 'function',
      'type': 'httpTrigger',
      'direction': 'in',
      'name': 'req',
      'methods': [
        'get'
      ]
    },
    {
      'type': 'http',
      'direction': 'out',
      'name': 'res'
    }
  ],
  'scriptFile': '../target/foobar/index.js'

Expected behavior
I expect to get the same list of firewall rules when i run my program locally or in an azure function.

Screenshots
N/A

Additional context
N/A

@ghost ghost added needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that labels Apr 25, 2022
@azure-sdk
Copy link
Collaborator

Label prediction was below confidence level 0.6 for Model:ServiceLabels: 'Azure.Identity:0.28440252,ARM:0.072985284,Storage:0.054815795'

@maorleger maorleger added the Mgmt This issue is related to a management-plane library. label Apr 25, 2022
@ghost ghost removed the needs-triage Workflow: This is a new issue that needs to be triaged to the appropriate team. label Apr 25, 2022
@qiaozha
Copy link
Member

qiaozha commented Apr 26, 2022

Thanks for reporting this, I will take a look.

@qiaozha qiaozha assigned MaryGao and unassigned qiaozha Apr 27, 2022
@qiaozha
Copy link
Member

qiaozha commented Apr 27, 2022

@MaryGao Can you help take a look at this issue ? Thanks

@MaryGao
Copy link
Member

MaryGao commented May 8, 2022

@blured75 I couldn't reproduce this in my azure function. I could get the same list both in local and azure function .

But when I published my local code to azure function I did encounter the authentication issue. Here are the steps:

  1. Everything works well in local function environment
  2. I published to my online azure function and tested my online function in portal referencing the doc
  3. In azure portal I checked the error log with message ... authenticate to your Azure account using 'az login'.at AzureCliCredential.getToken...
  4. Then followed the doc to grant the proper permission for my azure function in postgresql server
  5. Finally my azure function handled correctly

Please let me know if the steps are clear or not and share your message with us if still error!

@MaryGao MaryGao added the needs-author-feedback Workflow: More information is needed from author to address the issue. label May 8, 2022
@ghost ghost added the no-recent-activity There has been no recent activity on this issue. label May 15, 2022
@ghost
Copy link

ghost commented May 15, 2022

Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

@ghost ghost closed this as completed May 30, 2022
azure-sdk pushed a commit to azure-sdk/azure-sdk-for-js that referenced this issue Dec 8, 2022
Release app microsoft.app 2022 10 01 (Azure#21683)

* Adds base for updating Microsoft.App from version preview/2022-06-01-preview to version 2022-10-01

* Updates readme

* Updates API version in new specs and examples

* Add AppState and LatestReadyRevisionName (Azure#21034)

* Add new props

* add defaults

* Add swagger for client cert & CORS policy (Azure#21126)

* Fix password format of env domain for 2022-10-01 (Azure#21463)

* fix

* fix

* Remove AppState property as we decided to postpone it (Azure#21483)

* Remove AppState property as we decided to postpone it

* Fix swagger issues

* More swagger fixes

* s360 swagger correctness fixes (Azure#21472)

Co-authored-by: Nan Jiang <[email protected]>

* Add kind for managed environment (Azure#21589)

* add

* fix

* fix (Azure#21730)

* fix (Azure#21747)

Co-authored-by: p-bouchon <[email protected]>
Co-authored-by: Ruslan Yakushev <[email protected]>
Co-authored-by: zhenqxuMSFT <[email protected]>
Co-authored-by: najian <[email protected]>
Co-authored-by: Nan Jiang <[email protected]>
@github-actions github-actions bot locked and limited conversation to collaborators Apr 11, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. Mgmt This issue is related to a management-plane library. needs-author-feedback Workflow: More information is needed from author to address the issue. no-recent-activity There has been no recent activity on this issue. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

5 participants