diff --git a/.changeset/fair-bars-chew.md b/.changeset/fair-bars-chew.md new file mode 100644 index 000000000..c808c5076 --- /dev/null +++ b/.changeset/fair-bars-chew.md @@ -0,0 +1,5 @@ +--- +'@gradientedge/cdk-utils-azure': patch +--- + +Create deployment slots before dependent Web App deployment commands. diff --git a/packages/azure/src/construct/site-with-webapp/main.ts b/packages/azure/src/construct/site-with-webapp/main.ts index 909614695..da9f6deac 100644 --- a/packages/azure/src/construct/site-with-webapp/main.ts +++ b/packages/azure/src/construct/site-with-webapp/main.ts @@ -57,7 +57,6 @@ export class SiteWithWebApp extends CommonAzureConstruct { this.createCodePackage() this.createWebAppSiteConfig() this.createWebApp() - this.createWebAppSlot() this.createDiagnosticLog() } @@ -177,6 +176,7 @@ export class SiteWithWebApp extends CommonAzureConstruct { }, { ...resourceOptions } ) + this.createWebAppSlot() } /** @summary Create the optional Azure Web App deployment slot */ diff --git a/packages/azure/src/services/app-service/main.ts b/packages/azure/src/services/app-service/main.ts index 326ea4268..4e4257213 100644 --- a/packages/azure/src/services/app-service/main.ts +++ b/packages/azure/src/services/app-service/main.ts @@ -156,7 +156,7 @@ export class AzureAppServiceManager { `${id}-was`, { ...props, - name: scope.resourceNameFormatter.format(props.name?.toString(), scope.props.resourceNameOptions?.linuxWebApp), + name: props.name, resourceGroupName, location: props.location ?? scope.props.location, httpsOnly: props.httpsOnly ?? true, @@ -179,7 +179,11 @@ export class AzureAppServiceManager { ...props.tags, }, }, - { parent: scope, ...resourceOptions } + { + parent: scope, + ...resourceOptions, + ignoreChanges: [...new Set([...(resourceOptions?.ignoreChanges ?? []), 'siteConfig.autoSwapSlotName'])], + } ) } } diff --git a/packages/azure/test/constructs/site-with-webapp.test.ts b/packages/azure/test/constructs/site-with-webapp.test.ts index dc5f0f542..f2f64563b 100644 --- a/packages/azure/test/constructs/site-with-webapp.test.ts +++ b/packages/azure/test/constructs/site-with-webapp.test.ts @@ -243,9 +243,14 @@ describe('TestSiteWithWebAppConstruct', () => { test('provisions web app slot with auto-swap configuration', () => { pulumi - .all([stack.construct.site.webAppSlot?.id, stack.construct.site.webAppSlot?.siteConfig]) - .apply(([id, siteConfig]) => { + .all([ + stack.construct.site.webAppSlot?.id, + stack.construct.site.webAppSlot?.name, + stack.construct.site.webAppSlot?.siteConfig, + ]) + .apply(([id, name, siteConfig]) => { expect(id).toEqual('test-common-stack-web-app-slot-was-id') + expect(name).toEqual('test-site-web-app-dev') expect(siteConfig?.autoSwapSlotName).toEqual('production') }) }) diff --git a/packages/azure/test/services/app-service-manager.test.ts b/packages/azure/test/services/app-service-manager.test.ts index 1eef4f6e4..6f553513b 100644 --- a/packages/azure/test/services/app-service-manager.test.ts +++ b/packages/azure/test/services/app-service-manager.test.ts @@ -213,7 +213,7 @@ describe('TestAzureWebAppSlotConstruct', () => { expect(urn).toEqual( 'urn:pulumi:stack::project::construct:test-common-stack$azure-native:web:WebAppSlot::test-web-app-slot-dev-was' ) - expect(name).toEqual('test-linux-web-app-dev') + expect(name).toEqual('test-linux-web-app') expect(location).toEqual('eastus') expect(httpsOnly).toEqual(true) expect(tags?.environment).toEqual('dev')