mirror of
https://github.com/hanzoai/azure-sdk-for-js.git
synced 2026-10-30 19:51:51 +00:00
28 lines
1.1 KiB
TypeScript
28 lines
1.1 KiB
TypeScript
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
|
|
/**
|
|
* This sample demonstrates how to Check the availability of name for resource
|
|
*
|
|
* @summary Check the availability of name for resource
|
|
* x-ms-original-file: specification/postgresql/resource-manager/Microsoft.DBforPostgreSQL/stable/2017-12-01/examples/CheckNameAvailability.json
|
|
*/
|
|
|
|
import type { NameAvailabilityRequest } from "@azure/arm-postgresql";
|
|
import { PostgreSQLManagementClient } from "@azure/arm-postgresql";
|
|
import { DefaultAzureCredential } from "@azure/identity";
|
|
|
|
async function nameAvailability(): Promise<void> {
|
|
const subscriptionId = "ffffffff-ffff-ffff-ffff-ffffffffffff";
|
|
const nameAvailabilityRequest: NameAvailabilityRequest = {
|
|
name: "name1",
|
|
type: "Microsoft.DBforPostgreSQL",
|
|
};
|
|
const credential = new DefaultAzureCredential();
|
|
const client = new PostgreSQLManagementClient(credential, subscriptionId);
|
|
const result = await client.checkNameAvailability.execute(nameAvailabilityRequest);
|
|
console.log(result);
|
|
}
|
|
|
|
nameAvailability().catch(console.error);
|