Поделиться через


Клиентская библиотека Azure StorageManagement для JavaScript — версия 18.6.0

Этот пакет содержит isomorphic SDK (выполняется как в Node.js, так и в браузерах) для клиента Службы хранилища Azure.

API управления хранилищами Azure.

Source code | Package (NPM) | API reference documentation | Samples

Getting started

Поддерживаемые в настоящее время среды

See our support policy for more details.

Prerequisites

Установите пакет @azure/arm-storage.

Установите клиентскую библиотеку Azure StorageManagement для JavaScript с помощью npm:

npm install @azure/arm-storage

Создание и проверка подлинности StorageManagementClient

Чтобы создать клиентский объект для доступа к API Службы хранилища Azure, вам потребуется endpoint ресурс Azure StorageManagement и a credential. Клиент Azure StorageManagement может использовать учетные данные Azure Active Directory для проверки подлинности. You can find the endpoint for your Azure StorageManagement resource in the Azure Portal.

You can authenticate with Azure Active Directory using a credential from the @azure/identity library or an existing AAD Token.

To use the DefaultAzureCredential provider shown below, or other credential providers provided with the Azure SDK, please install the @azure/identity package:

npm install @azure/identity

Кроме того, необходимо зарегистрировать новое приложение AAD и предоставить доступ к Службе хранилища Azure , назначив подходящую роль субъекту-службе (обратите внимание: роли, такие как "Owner" не будут предоставлять необходимые разрешения).

For more information about how to create an Azure AD Application check out this guide.

Используя среды Node.js и node-like, можно использовать класс DefaultAzureCredential для проверки подлинности клиента.

import { StorageManagementClient } from "@azure/arm-storage";
import { DefaultAzureCredential } from "@azure/identity";

const subscriptionId = "00000000-0000-0000-0000-000000000000";
const client = new StorageManagementClient(new DefaultAzureCredential(), subscriptionId);

Для сред браузера используйте InteractiveBrowserCredential из пакета @azure/identity для проверки подлинности.

import { InteractiveBrowserCredential } from "@azure/identity";
import { StorageManagementClient } from "@azure/arm-storage";

const subscriptionId = "00000000-0000-0000-0000-000000000000";
const credential = new InteractiveBrowserCredential({
  tenantId: "<YOUR_TENANT_ID>",
  clientId: "<YOUR_CLIENT_ID>",
});
const client = new StorageManagementClient(credential, subscriptionId);

JavaScript Bundle

Чтобы использовать эту клиентную библиотеку в браузере, сначала необходимо использовать пакет. For details on how to do this, please refer to our bundling documentation.

Key concepts

StorageManagementClient

StorageManagementClient — это основной интерфейс для разработчиков с помощью клиентской библиотеки Службы хранилища Azure. Изучите методы этого клиентского объекта, чтобы понять различные функции службы хранилища Azure StorageManagement, к которым можно получить доступ.

Troubleshooting

Logging

Включение ведения журнала может помочь выявить полезные сведения о сбоях. Чтобы просмотреть журнал HTTP-запросов и ответов, задайте для переменной среды AZURE_LOG_LEVEL значение info. В альтернативном порядке, логирование можно включить во время выполнения, вызвав setLogLevel в @azure/logger:

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

setLogLevel("info");

Дополнительные инструкции по включению журналов см. в документации по пакету @azure/loger.

Next steps

Please take a look at the samples directory for detailed examples on how to use this library.

Contributing

If you'd like to contribute to this library, please read the contributing guide to learn more about how to build and test the code.