Last active
October 20, 2025 16:56
-
-
Save mirontoli/c1ea2cd4e81335113818edef247113d8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # execute in bash | |
| stacks=$(az stack sub list --query "[?starts_with(name, 'stack-iac-demo')].name" -o tsv) | |
| for name in $stacks; do az stack sub delete --name "$name" --action-on-unmanage deleteAll --yes; done |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trigger: | |
| - main | |
| variables: | |
| azureSubscription: "demo-azure-connection" | |
| pool: | |
| vmImage: ubuntu-latest | |
| steps: | |
| - task: AzureCLI@2 | |
| displayName: "Deploy Infrastructure" | |
| inputs: | |
| azureSubscription: "$(azureSubscription)" | |
| scriptType: bash | |
| scriptLocation: inlineScript | |
| useGlobalConfig: false | |
| inlineScript: | | |
| az stack sub create \ | |
| --template-file ./infra/main.bicep \ | |
| --name stack-iac-demo \ | |
| --location westeurope \ | |
| --action-on-unmanage deleteResources \ | |
| --deny-settings-mode None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| targetScope = 'subscription' | |
| param appName string = 'iac-demo' | |
| param location string = 'westeurope' | |
| var resourceGroupName = 'rg-${appName}' | |
| resource newRG 'Microsoft.Resources/resourceGroups@2024-11-01' = { | |
| name: resourceGroupName | |
| location: location | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trigger: | |
| - main | |
| variables: | |
| azureSubscription: "demo-azure-connection" | |
| pool: | |
| vmImage: ubuntu-latest | |
| # THIS IS NEW for STEP 3: stages | |
| stages: | |
| - stage: DeployDEV | |
| displayName: "Deploy to DEV" | |
| jobs: | |
| - deployment: DeployInfraDEV | |
| displayName: "Deploy Infrastructure to DEV" | |
| environment: "DEV" # The name is important | |
| strategy: | |
| runOnce: | |
| deploy: | |
| # END OF NEW for STEP 3: stages | |
| steps: | |
| # THIS IS NEW for STEP 3: source code | |
| - checkout: self | |
| displayName: "Checkout source code" | |
| # END OF NEW for STEP 3: source code | |
| - task: AzureCLI@2 | |
| displayName: "Deploy Infrastructure" | |
| inputs: | |
| azureSubscription: "$(azureSubscription)" | |
| scriptType: bash | |
| scriptLocation: inlineScript | |
| useGlobalConfig: false | |
| inlineScript: | | |
| az stack sub create \ | |
| --template-file ./infra/main.bicep \ | |
| --name stack-iac-demo \ | |
| --location westeurope \ | |
| --action-on-unmanage deleteResources \ | |
| --deny-settings-mode None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trigger: | |
| - main | |
| variables: | |
| azureSubscription: "demo-azure-connection" | |
| pool: | |
| vmImage: ubuntu-latest | |
| stages: | |
| - stage: DeployDEV | |
| displayName: "Deploy to DEV" | |
| jobs: | |
| - template: pipelines/templates/deploy.yml | |
| parameters: | |
| environment: "DEV" | |
| azureSubscription: "$(azureSubscription)" | |
| stackName: "stack-iac-demo-dev" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| parameters: | |
| - name: environment | |
| type: string | |
| - name: azureSubscription | |
| type: string | |
| - name: stackName | |
| type: string | |
| - name: location | |
| type: string | |
| default: "westeurope" | |
| jobs: | |
| - deployment: DeployInfra${{ parameters.environment }} | |
| displayName: "Deploy Infrastructure to ${{ parameters.environment }}" | |
| environment: "${{ parameters.environment }}" | |
| strategy: | |
| runOnce: | |
| deploy: | |
| steps: | |
| - checkout: self | |
| displayName: "Checkout source code" | |
| - task: AzureCLI@2 | |
| displayName: "Deploy Infrastructure to ${{ parameters.environment }}" | |
| inputs: | |
| azureSubscription: "${{ parameters.azureSubscription }}" | |
| scriptType: bash | |
| scriptLocation: inlineScript | |
| useGlobalConfig: false | |
| inlineScript: | | |
| az stack sub create \ | |
| --template-file ./infra/main.bicep \ | |
| --name ${{ parameters.stackName }} \ | |
| --location ${{ parameters.location }} \ | |
| --action-on-unmanage deleteResources \ | |
| --deny-settings-mode None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using '../main.bicep' | |
| param environment = 'DEV' | |
| param appName = 'iac-demo' | |
| param location = 'westeurope' | |
| param resourceGroupName = 'rg-${appName}-${environment}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| targetScope = 'subscription' | |
| // THIS IS NEW for step 5 | |
| @description('Environment name (e.g., DEV, TEST, PROD)') | |
| @allowed(['DEV', 'TEST', 'PROD']) | |
| param environment string = 'DEV' | |
| // END OF NEW for step 5 | |
| param appName string = 'iac-demo' | |
| param location string = 'westeurope' | |
| // REPLACE THIS LINE WITH THE NEXT ONE, STEP 5 | |
| // var resourceGroupName = 'rg-${appName}' | |
| param resourceGroupName string = 'rg-${appName}-${environment}' | |
| resource newRG 'Microsoft.Resources/resourceGroups@2024-11-01' = { | |
| name: resourceGroupName | |
| location: location | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| parameters: | |
| - name: environment | |
| type: string | |
| - name: azureSubscription | |
| type: string | |
| - name: stackName | |
| type: string | |
| - name: location | |
| type: string | |
| default: "westeurope" | |
| jobs: | |
| - deployment: DeployInfra${{ parameters.environment }} | |
| displayName: "Deploy Infrastructure to ${{ parameters.environment }}" | |
| environment: "${{ parameters.environment }}" | |
| strategy: | |
| runOnce: | |
| deploy: | |
| steps: | |
| - checkout: self | |
| displayName: "Checkout source code" | |
| - task: AzureCLI@2 | |
| displayName: "Deploy Infrastructure to ${{ parameters.environment }}" | |
| inputs: | |
| azureSubscription: "${{ parameters.azureSubscription }}" | |
| scriptType: bash | |
| scriptLocation: inlineScript | |
| useGlobalConfig: false | |
| inlineScript: | | |
| az stack sub create \ | |
| --template-file ./infra/main.bicep \ | |
| # THIS IS NEW for step 5: parameters | |
| --parameters ./infra/parameters/${{ parameters.environment }}.bicepparam \ | |
| # END OF NEW for step 5: parameters | |
| --name ${{ parameters.stackName }} \ | |
| --location ${{ parameters.location }} \ | |
| --action-on-unmanage deleteResources \ | |
| --deny-settings-mode None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| trigger: | |
| - main | |
| variables: | |
| azureSubscription: 'demo-azure-connnection' | |
| pool: | |
| vmImage: ubuntu-latest | |
| stages: | |
| - stage: DeployDEV | |
| displayName: 'Deploy to DEV' | |
| jobs: | |
| - template: pipelines/templates/deploy.yml | |
| parameters: | |
| environment: 'DEV' | |
| azureSubscription: '$(azureSubscription)' | |
| stackName: 'stack-iac-demo-dev' | |
| - stage: DeployTEST | |
| displayName: 'Deploy to TEST' | |
| jobs: | |
| - template: pipelines/templates/deploy.yml | |
| parameters: | |
| environment: 'TEST' | |
| azureSubscription: '$(azureSubscription)' | |
| stackName: 'stack-iac-demo-test' | |
| - stage: DeployPROD | |
| displayName: 'Deploy to PROD' | |
| jobs: | |
| - template: pipelines/templates/deploy.yml | |
| parameters: | |
| environment: 'PROD' | |
| azureSubscription: '$(azureSubscription)' | |
| stackName: 'stack-iac-demo-prod' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using '../main.bicep' | |
| param environment = 'PROD' | |
| param appName = 'iac-demo' | |
| param location = 'westeurope' | |
| param resourceGroupName = 'rg-${appName}-${environment}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using '../main.bicep' | |
| param environment = 'TEST' | |
| param appName = 'iac-demo' | |
| param location = 'westeurope' | |
| param resourceGroupName = 'rg-${appName}-${environment}' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @description('The name of the Static Web App') | |
| param staticWebAppName string | |
| @description('The location for the Static Web App') | |
| param location string | |
| @description('Environment name for tagging') | |
| param environment string | |
| @description('The SKU for the Static Web App') | |
| @allowed(['Free', 'Standard']) | |
| param sku string = 'Free' | |
| resource staticWebApp 'Microsoft.Web/staticSites@2024-11-01' = { | |
| name: staticWebAppName | |
| location: location | |
| tags: { | |
| Environment: environment | |
| } | |
| sku: { | |
| name: sku | |
| tier: sku | |
| } | |
| properties: {} | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| targetScope = 'subscription' | |
| @description('Environment name (e.g., DEV, TEST, PROD)') | |
| @allowed(['DEV', 'TEST', 'PROD']) | |
| param environment string = 'DEV' | |
| param appName string = 'iac-demo' | |
| param location string = 'westeurope' | |
| param resourceGroupName string = 'rg-${appName}-${environment}' | |
| resource newRG 'Microsoft.Resources/resourceGroups@2024-11-01' = { | |
| name: resourceGroupName | |
| location: location | |
| } | |
| //NEW FOR STEP 7 | |
| module staticWebAppModule 'modules/static-web-app.bicep' = { | |
| name: 'staticWebAppDeployment' | |
| scope: newRG | |
| params: { | |
| staticWebAppName: 'swa-iac-demo-${environment}' | |
| location: location | |
| environment: environment | |
| sku: 'Free' | |
| } | |
| } | |
| //END OF NEW FOR STEP 7 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Hello World |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| parameters: | |
| - name: environment | |
| type: string | |
| - name: azureSubscription | |
| type: string | |
| - name: stackName | |
| type: string | |
| - name: location | |
| type: string | |
| default: "westeurope" | |
| jobs: | |
| - deployment: DeployInfra${{ parameters.environment }} | |
| displayName: "Deploy Infrastructure to ${{ parameters.environment }}" | |
| environment: "${{ parameters.environment }}" | |
| strategy: | |
| runOnce: | |
| deploy: | |
| steps: | |
| - checkout: self | |
| displayName: "Checkout source code" | |
| - task: AzureCLI@2 | |
| displayName: "Deploy Infrastructure to ${{ parameters.environment }}" | |
| inputs: | |
| azureSubscription: "${{ parameters.azureSubscription }}" | |
| scriptType: bash | |
| scriptLocation: inlineScript | |
| useGlobalConfig: false | |
| inlineScript: | | |
| az stack sub create \ | |
| --template-file ./infra/main.bicep \ | |
| --parameters ./infra/parameters/${{ parameters.environment }}.bicepparam \ | |
| --name ${{ parameters.stackName }} \ | |
| --location ${{ parameters.location }} \ | |
| --action-on-unmanage deleteResources \ | |
| --deny-settings-mode None | |
| // NEW FOR STEP 8 | |
| - task: UseNode@1 | |
| inputs: | |
| version: '22.x' | |
| - task: Npm@1 | |
| displayName: 'Install SWA CLI' | |
| inputs: | |
| command: 'custom' | |
| customCommand: 'install -g @azure/static-web-apps-cli' | |
| - task: AzureCLI@2 | |
| displayName: 'Deploy Static Web App ${{ parameters.environment }}' | |
| inputs: | |
| azureSubscription: '$(azureSubscription)' | |
| scriptType: bash | |
| scriptLocation: inlineScript | |
| useGlobalConfig: false | |
| inlineScript: | | |
| export SWA_CLI_DEPLOYMENT_TOKEN=$(az staticwebapp secrets list --name swa-iac-demo-${{ parameters.environment }} --query "properties.apiKey" -o tsv) | |
| swa deploy ./src --env Production | |
| // END OF NEW FOR STEP 8 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment