Test of migration of Azure Container Apps from Microsoft.Web to Microsoft.App namespace.
To run:
npm install
pulumi up
Pulumi sees this migration as the old resources being removed and the new resources being created. Therefore to replicate the migration in our Pulumi state we're doing two steps:
- Drop the resources being migrated from being managed by Pulumi.
- Importing the new migrated resources back into our Pulumi stack
Add the retainOnDelete
resource option to the resources which are going to be migrated.
This option allows us to remove the code for the resources once they've changed namespace without attempting to delete the underlying cloud resources. The resources will only be removed from our Pulumi stack state.
Once the cloud resources have been migrated by Microsoft, update your resources (examples below in Typescript but should be approximately the same in any other supported Pulumi language).
-
Update your imports:
- import * as web from "@pulumi/azure-native/web"; + import * as app from "@pulumi/azure-native/app";
-
Update resource namespaces based on resource update:
- Update the import namespace.
- Change
KubeEnvironment
toManagedEnvironment
- Change the Pulumi ID for the resource
- const environment = new web.KubeEnvironment("kubeEnvironment", { + const environment = new app.ManagedEnvironment("managedEnvironment", {
- const containerApp = new web.ContainerApp("containerApp", { + const containerApp = new app.ContainerApp("containerAppImported", {
-
Fix arguments which have been renamed e.g.
const containerApp = new app.ContainerApp("containerAppImported", { - kubeEnvironmentId: environment.id, + managedEnvironmentId: environment.id,
-
Add import options for the migrated resources
- Add the
import
option with the Resource ID for each resource (this can be found in the JSON view in the portal).
const kubeEnvironment = new app.ManagedEnvironment( "managedEnvironment", { // args }, + { + // opts + import: + "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourceGroupXXXXXXXX/providers/Microsoft.App/managedenvironment+ s/environmentcXXXXXXX", + ignoreChanges: [ + "appLogsConfiguration.logAnalyticsConfiguration.sharedKey", // this is a write-only property + ], + } ); const containerApp = new app.ContainerApp( "containerAppImported", { // args }, + { + // opts + import: + "/subscriptions/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/resourceGroupXXXXXXXX/providers/Microsoft.App/containerApps/container-app", + ignoreChanges: [ // Default values + "configuration.activeRevisionsMode", + "configuration.ingress.allowInsecure", + "template.scale", + ], + } );
Tip: if you get a message saying "inputs to import do not match the existing resource" during preview, expand the details to show a diff of what doesn't match. You can fix these import differences by changing your code to match, or adding to the
ignoreChanges
options if it's just a default value. - Add the
-
Run a pulumi deployment to complete the import.
-
Remove the
import
andignoreChanges
before the next deploy. -
If you'd like the resources to have their original name, add an alias for the old name (this can be removed again once a deploy has been completed):
const containerApp = new app.ContainerApp( - "containerAppImported", + "containerApp", { // args }, + { + // opts + alias: [{ name: "containerAppImported" }] + } );