Pulumi Azure Native Has Slimmed Down for Summer

Pulumi has just announced the release of v3 of the Azure Native SDK. The headline feature is that the library has been reduced in size by 75%. Let’s look at what that means and what you need to know.

Azure Native SDK

As a quick reminder, the Azure Native SDK is the library you can use to deploy Azure resources using Pulumi. The “Native” part indicates that the SDK is auto-generated from the Azure ARM API, which means it covers 100% of Azure resources, so long as they are in the ARM API, with support for all properties. It also means that new resources are added as soon as they are released.

Size Reductions

So why is a size reduction needed, and how has it been achieved? If you’re familiar with the ARM API or using Bicep, you’ll know that each Azure resource has an API version, which looks you will know t something like 2025-02-01, indicating which version of the ARM API is being used. As Azure resources add new features or change how they are deployed, new API versions are added. Most Azure resources have multiple API versions, some with a long list.

The v2 of the Pulumi Azure native SDK supports the current and all previous API versions of all Azure resources. Each resource has a default API version selected by Pulumi, usually the latest version when v2 was released, but it is possible to specify older or newer API versions. For example, a deployment of a storage account with the default API version would look something like this:

const storageAccount = new azure_native.storage.StorageAccount("storageAccount", { ...

But if we need to use a specific API version, let’s say 2024-01-01, we can do:

const storageAccount = new azure_native.storage.20240101.StorageAccount("storageAccount", {

This approach makes it very easy to use older or newer versions of the APIs when needed, but the downside is that each new version increases the size of the SDK, which has grown significantly over time. This has culminated in issues with hitting size limits and adding new versions.

Given that most users use the default version most of the time, Pulumi has decided to remove non-default versions in the v3 SDK, which has resulted in a much smaller SDK. If you only use the default version for your deployments, you can probably stop reading here and enjoy the smaller SDK.

What About Non-Default Versions?

The obvious question this leads to is, what if I need non-default versions? Am I stuck now? Fortunately, there is a way to add these API versions. They have been extracted into separate packages that can be installed separately, so you only need to install the versions you need.

You can add the package you require with the pulumi package add command:

pulumi package add azure-native storage v20240101

Then we can import and use that in our code:

using Storage_v20240101 = Pulumi.AzureNative_Storage_v20240101;
...
 var storageAccount = new Storage_v20240101.Storage.StorageAccount("sa", new()
        {....

Pulumi Generic Resource

An alternative option to importing the required packages is to use the Pulumi Azure Generic resource. This allows you to deploy any Azure resource, regardless of API version. The generic resource is not type-safe, and it’s on you as the developer to ensure you set all the required properties. Generally, you want to avoid this and use the API specific packages to get full type-safety, intellisense, etc.

You can read more details on the generic resource here.