Announcing Azure SDK for Node.js 2.0 preview

Today we&;re excited to announce the 2.0 preview of the Azure SDK for Node.js. This update is packed with features to help you be more productive and we&039;ve added 20 new modules for services such as SQL and DocumentDB management.

As usage of the Azure SDK for Node.js continues to grow, we&039;ve received a lot of feedback from the community on how the SDK helps Node.js developers build on Azure and how some changes could make them more productive. With that feedback in mind, we set out to make some significant improvements to the developer experience, which includes enhancements to the modules themselves as well as some updates to make working in Visual Studio Code better.

Keep in mind that, as this is a preview release, it&039;s incredibly important to share your feedback with us on any issues or delightful experiences you face. Please open an issue on GitHub or connect with us directly on the Azure Developers Slack team with any questions or feedback.

Promises

With the way the module is being used, we&039;ve seen a lot of opportunities to improve the code that people are writing and maintaining.

This also makes it possible to use async and await in TypeScript or ES2017 environments.

Updated typings

Visual Studio Code&039;s rich Intellisense support makes building apps much quicker and more intuitive. Building with the Azure SDK is no exception and the typings have been updated and improved to provide you with the best possible experience.

New modules

Aside from the updates to the existing modules, this update includes the preview release of 20 new modules.

Advisor Management (azure-arm-advisor)
Automation Management (azure-arm-automation)
Billing Management (azure-arm-billing)
Cognitive Services Management (azure-arm-cognitiveservices)
Container Registry Management (azure-arm-containerregistry)
Customer Insights Management (azure-arm-customerinsights)
DocumentDB Management (azure-arm-documentdb)
Logic Management (azure-arm-logic)
Machine Learning Management (azure-arm-machinelearning)
Media Services Management (azure-arm-mediaservices)
Operational Insights Management (azure-arm-operationalinsights)
Recovery Services Backup Management (azure-arm-recoveryservicesbackup)
Recovery Services Management (azure-arm-recoveryservices)
Relay Management (azure-arm-relay)
Scheduler Management (azure-arm-scheduler)
Search Management (azure-arm-search)
ServiceFabric Management (azure-arm-servicefabric)
ServiceMap Management (azure-arm-servicemap)
SQL Management (azure-arm-sql)
Storage Import Export Management (azure-arm-storageimportexport)

Moving to the preview

Migrating to the preview is low in complexity and should be a direct replacement without changes to your code. When migrating to the preview it&039;s important to note that because of new implementation, using ES6 features, Node.js version 6.x is required. All of the existing callback-based methods will continue to work; however, omitting the final parameter will result in the method returning a promise.

Sending custom requests

With new updates to the runtime ms-rest and ms-rest-azure, you can make generic requests to Azure with the authenticated client. This is useful when debugging an issue or for making custom requests to the Azure API.

The following example makes a custom, long running request to get all resource groups in a subscriptions then writes the result to standard out. Detailed documentation is available on GitHub.

const msrest = require(&039;ms-rest&039;);
const msRestAzure = require(&039;ms-rest-azure&039;);

const clientId = process.env[&039;CLIENT_ID&039;];
const secret = process.env[&039;APPLICATION_SECRET&039;];
const domain = process.env[&039;DOMAIN&039;]; // Also known as tenantId.
const subscriptionId = process.env[&039;AZURE_SUBSCRIPTION_ID&039;];

msRestAzure.loginWithServicePrincipalSecret(clientId, secret, domain).then((creds) => {
let client = new msRestAzure.AzureServiceClient(creds);

let options = {
method: &039;GET&039;,
url: `https://management.azure.com/subscriptions/${subscriptionId}/resourcegroups?api-version=2016-09-01`,
headers: {
&039;user-agent&039;: &039;MyTestApp/1.0&039;
}
};

return client.sendLongRunningRequest(options);
})
.then(console.dir.bind(console))
.catch(console.error.bind(console));
Quelle: Azure

Published by