The Pulumi Azure and Azure NextGen providers can be used from within the same Pulumi project to allow you to migrate to the new provider at your own pace. This means it is also possible to migrate existing resources from the Azure provider to the Azure NextGen provider with no impact or downtime to existing resources.
At a high-level the steps to do this are:
- Add the Pulumi Azure NextGen provider to your current Pulumi project - e.g.
npm install @pulumi/azure-nextgen
. - Use the
pulumi import
command to import your existing resource into your stack as a NextGen resource. - Update all references to the old resource to reference the new NextGen resource.
- Use the
pulumi state delete
command to remove the old resource from your state file. - Remove the code for the old resource from your Pulumi project.
- Done.
This Pulumi application will create two resources, a azure.core.ResourceGroup
and a azure.storage.Account
, and we will migrate the azure.core.ResourceGroup
to the equivalent azure_nextgen.resources.latest.ResourceGroup
in the Azure NextGen provider.
Using the Example Code below the steps would be:
- Create resources to create resources using the Azure provider that we will migrate to the Azure NextGen provider.
pulumi up -y
- Install the Azure NextGen provider.
npm install @pulumi/azure-nextgen
- Import the Azure
ResourceGroup
as a NextGenResourceGroup
.pulumi import azure-nextgen:resources/latest:ResourceGroup main /subscriptions/32b9cb2e-69be-4040-80a6-02cd6b2cc5ec/resourceGroups/mainfbed5cc7
- Copy and paste the code output from the previous command into your
index.ts
and update all references to the old resource to reference the newmain
NextGen resource. - Run
pulumi up
to ensure no changes are anticipated in the preview. - Remove the Azure
ResourceGroup
from Pulumi's state file.pulumi state delete 'urn:pulumi:dev::p-azure-nextgen-migration::azure:core/resourceGroup:ResourceGroup::main'
.- Note: the
urn
value will be different for your Pulumi stack. You can see theurn
for your ResourceGroup withpulumi stack --show-urns
.
- Remove the code for the Azure
ResourceGroup
from yourindex.ts
. - Run
pulumi up
to ensure no changes are anticipated in the preview.