Files

27 lines
1.0 KiB
TypeScript

// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.
/**
* This sample demonstrates how to List all the servers in a given resource group.
*
* @summary List all the servers in a given resource group.
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/ServerListByResourceGroup.json
*/
import { PostgreSQLManagementClient } from "@azure/arm-postgresql";
import { DefaultAzureCredential } from "@azure/identity";
async function serverListByResourceGroup(): Promise<void> {
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
const resourceGroupName = "TestGroup";
const credential = new DefaultAzureCredential();
const client = new PostgreSQLManagementClient(credential, subscriptionId);
const resArray = new Array();
for await (const item of client.servers.listByResourceGroup(resourceGroupName)) {
resArray.push(item);
}
console.log(resArray);
}
serverListByResourceGroup().catch(console.error);