1.0.0-beta.1 • Published 8 days ago

@azure-rest/arm-appservice v1.0.0-beta.1

Weekly downloads
-
License
MIT
Repository
github
Last release
8 days ago

Azure WebSitemManagement REST client library for JavaScript

App Service Client

If you are not familiar with our REST client, please spend 5 minutes to take a look at our REST client docs to use this library, the REST client provides a light-weighted & developer friendly way to call azure rest api

Key links:

Getting started

Currently supported environments

  • Node.js version 14.x.x or higher

Prerequisites

Install the @azure-rest/arm-appservice package

Install the Azure WebSiteManagement client REST client library for JavaScript with npm:

npm install @azure-rest/arm-appservice

Create and authenticate a WebSiteManagementClient

To use an Azure Active Directory (AAD) token credential, provide an instance of the desired credential type obtained from the @azure/identity library.

To authenticate with AAD, you must first npm install @azure/identity

After setup, you can choose which type of credential from @azure/identity to use. As an example, DefaultAzureCredential can be used to authenticate the client:

Set the values of the client ID, tenant ID, and client secret of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID, AZURE_CLIENT_SECRET

Use the returned token credential to authenticate the client:

import WebSiteManagementClient from "@azure-rest/arm-appservice";
import { DefaultAzureCredential } from "@azure/identity";
const credential = new DefaultAzureCredential();
const client = WebSiteManagementClient(credential);

Examples

The following section shows you how to initialize and authenticate your client, then list all of your App Service Plans.

List All App Service Plans

import WebSiteManagementClient, { paginate }  from "@azure-rest/arm-appservice";
import { DefaultAzureCredential } from "@azure/identity";

async function listAppServicePlans() {
  const subscriptionId = process.env.SUBSCRIPTION_ID as string;
  const credential = new DefaultAzureCredential();
  const client = WebSiteManagementClient(credential);
  const result = [];
  const initialResposne = await client
    .path("/subscriptions/{subscriptionId}/providers/Microsoft.Web/serverfarms", subscriptionId)
    .get();
  const res = paginate(client, initialResposne);
  for await (let item of res) {
    result.push(item);
  }
  console.log(result);
}

listAppServicePlans().catch(console.error);

Troubleshooting

Logging

Enabling logging may help uncover useful information about failures. In order to see a log of HTTP requests and responses, set the AZURE_LOG_LEVEL environment variable to info. Alternatively, logging can be enabled at runtime by calling setLogLevel in the @azure/logger:

import { setLogLevel } from "@azure/logger";

setLogLevel("info");

For more detailed instructions on how to enable logs, you can look at the @azure/logger package docs.

1.0.0-beta.1

2 years ago