|
| 1 | +# ---------------------------------------------------------------------------------- |
| 2 | +# Copyright (c) Microsoft Corporation. |
| 3 | +# Licensed under the MIT license. |
| 4 | +# |
| 5 | +# THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, |
| 6 | +# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES |
| 7 | +# OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE. |
| 8 | +# ---------------------------------------------------------------------------------- |
| 9 | + |
| 10 | +parameters: |
| 11 | + - name: workingDir |
| 12 | + type: string |
| 13 | + - name: deployOperation |
| 14 | + type: string |
| 15 | + default: create |
| 16 | + values: |
| 17 | + - create |
| 18 | + - what-if |
| 19 | + - name: identityManagementGroupId |
| 20 | + type: string |
| 21 | + - name: identitySubscriptionId |
| 22 | + type: string |
| 23 | + - name: identityRegion |
| 24 | + type: string |
| 25 | + - name: identityConfigurationPath |
| 26 | + type: string |
| 27 | + |
| 28 | +steps: |
| 29 | + |
| 30 | +- task: PowerShell@2 |
| 31 | + displayName: Validate identity Parameters |
| 32 | + inputs: |
| 33 | + targetType: 'inline' |
| 34 | + script: | |
| 35 | + $schemaFile="$(Build.SourcesDirectory)/schemas/latest/landingzones/lz-platform-identity.json" |
| 36 | +
|
| 37 | + Write-Host "Parameters File: ${{ parameters.identityConfigurationPath }}" |
| 38 | + Write-Host "Schema File: ${schemaFile}" |
| 39 | +
|
| 40 | + Get-Content -Raw "${{ parameters.identityConfigurationPath }}" | Test-Json -SchemaFile "${schemaFile}" |
| 41 | +
|
| 42 | +- template: ./move-subscription.yml |
| 43 | + parameters: |
| 44 | + managementGroup: ${{ parameters.identityManagementGroupId }} |
| 45 | + subscriptionGuid: ${{ parameters.identitySubscriptionId }} |
| 46 | + subscriptionLocation: ${{ parameters.identityRegion }} |
| 47 | + templateDirectory: $(Build.SourcesDirectory)/landingzones/utils/mg-move |
| 48 | + templateFile: move-subscription.bicep |
| 49 | + workingDir: ${{ parameters.workingDir }}/utils/mg-move |
| 50 | + |
| 51 | +- task: AzureCLI@2 |
| 52 | + displayName: Configure Identity LZ |
| 53 | + inputs: |
| 54 | + azureSubscription: $(serviceConnection) |
| 55 | + scriptType: 'bash' |
| 56 | + scriptLocation: 'inlineScript' |
| 57 | + inlineScript: | |
| 58 | + $(var-bashPreInjectScript) |
| 59 | +
|
| 60 | + # Check if the log analytics workspace id is provided in the parameters json. |
| 61 | + # If present, then do no change it. Otherwise add it to the json parameter file. |
| 62 | + LOG_ANALYTICS_WORKSPACE_RESOURCE_ID_IN_PARAMETERS=`jq -r .parameters.logAnalyticsWorkspaceResourceId.value ${{ parameters.identityConfigurationPath }}` |
| 63 | +
|
| 64 | + if [[ $LOG_ANALYTICS_WORKSPACE_RESOURCE_ID_IN_PARAMETERS != null && "$LOG_ANALYTICS_WORKSPACE_RESOURCE_ID_IN_PARAMETERS" != "" ]]; |
| 65 | + then |
| 66 | + echo "Log Analytics Workspace Resource ID is set in ${{ parameters.identityConfigurationPath }} to $LOG_ANALYTICS_WORKSPACE_RESOURCE_ID_IN_PARAMETERS" |
| 67 | + else |
| 68 | + echo "Log Analytics Workspace Resource ID is not set in ${{ parameters.identityConfigurationPath }}. Updating ${{ parameters.identityConfigurationPath }} with $(var-logging-logAnalyticsWorkspaceResourceId)" |
| 69 | +
|
| 70 | + # use jq to update the json parameter file |
| 71 | + echo "$( jq '.parameters.logAnalyticsWorkspaceResourceId.value = "$(var-logging-logAnalyticsWorkspaceResourceId)"' ${{ parameters.identityConfigurationPath }} )" > ${{ parameters.identityConfigurationPath }} |
| 72 | + fi |
| 73 | +
|
| 74 | + echo "Deploying main.bicep using ${{ parameters.deployOperation}} operation using ${{ parameters.identityConfigurationPath }}..." |
| 75 | + |
| 76 | + az deployment sub ${{ parameters.deployOperation }} \ |
| 77 | + --location ${{ parameters.identityRegion }} \ |
| 78 | + --subscription ${{ parameters.identitySubscriptionId }} \ |
| 79 | + --template-file main.bicep \ |
| 80 | + --parameters @${{ parameters.identityConfigurationPath }} |
| 81 | + |
| 82 | + $(var-bashPostInjectScript) |
| 83 | + workingDirectory: '${{ parameters.workingDir }}/lz-platform-identity' |
0 commit comments