Passer au contenu principal

 Subscribe

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'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'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'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've seen a lot of opportunities to improve the code that people are writing and maintaining.

promises

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

typescript-async

Updated typings

Visual Studio Code'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.

typings

New modules

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

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'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('ms-rest');
const msRestAzure = require('ms-rest-azure');

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

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

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

  return client.sendLongRunningRequest(options);
})
.then(console.dir.bind(console))
.catch(console.error.bind(console));
  • Explore

     

    Let us know what you think of Azure and what you would like to see in the future.

     

    Provide feedback

  • Build your cloud computing and Azure skills with free courses by Microsoft Learn.

     

    Explore Azure learning


Join the conversation