added parameter update workflow
This commit is contained in:
Родитель
cb7916cc8c
Коммит
5f33fba92e
|
@ -1,301 +0,0 @@
|
|||
name: Create New Data Node
|
||||
|
||||
trigger: none
|
||||
|
||||
parameters:
|
||||
- name: devOpsOrgName
|
||||
displayName: DevOps Org Name
|
||||
type: string
|
||||
default: '<your-devops-org-name>'
|
||||
- name: devOpsPatToken
|
||||
displayName: DevOps PAT Token
|
||||
type: string
|
||||
- name: sourceProjectName
|
||||
displayName: Source Project Name
|
||||
type: string
|
||||
default: '<your-source-project-name>'
|
||||
- name: sourceRepositoryName
|
||||
displayName: Source Repository Name
|
||||
type: string
|
||||
default: '<your-source-repository-name>'
|
||||
- name: destinationProjectName
|
||||
displayName: Destination Project Name
|
||||
type: string
|
||||
default: '<your-destination-project-name>'
|
||||
- name: destinationRepositoryName
|
||||
displayName: Destination Repository Name
|
||||
type: string
|
||||
default: '<your-destination-repository-name>'
|
||||
- name: location
|
||||
displayName: Location
|
||||
type: string
|
||||
default: 'North Europe'
|
||||
- name: locationId
|
||||
displayName: Location Id
|
||||
type: string
|
||||
default: 'northeurope'
|
||||
- name: subscriptionId
|
||||
displayName: Subscription ID
|
||||
type: string
|
||||
default: '<your-subscription-id>'
|
||||
- name: resourceGroupName
|
||||
displayName: Resource Group Name
|
||||
type: string
|
||||
default: '<your-data-domain-resource-group-name>'
|
||||
- name: vnetResourceGroupName
|
||||
displayName: VNet Resource Group name
|
||||
type: string
|
||||
default: '<your-vnet-resource-group-name>'
|
||||
- name: vnetName
|
||||
displayName: VNet Name
|
||||
type: string
|
||||
default: '<your-vnet-name>'
|
||||
- name: privateLinkSubnetName
|
||||
displayName: Private Link Subnet Name
|
||||
type: string
|
||||
default: '<your-private-link-subnet-name>'
|
||||
- name: databricksName
|
||||
displayName: Databricks Name
|
||||
type: string
|
||||
default: '<your-databricks-name>'
|
||||
- name: databricksResourceGroupName
|
||||
displayName: Databricks Resource Group Name
|
||||
type: string
|
||||
default: '<your-databricks-resource-group-name>'
|
||||
- name: databricksPrivateSubnetName
|
||||
displayName: Databricks Private Subnet Name
|
||||
type: string
|
||||
default: '<your-databricks-private-subnet>'
|
||||
- name: databricksPublicSubnetName
|
||||
displayName: Databricks Public Subnet Name
|
||||
type: string
|
||||
default: '<your-databricks-public-subnet>'
|
||||
- name: dataFactoryName
|
||||
displayName: DataFactoryName
|
||||
type: string
|
||||
default: '<your-data-factory-name>'
|
||||
- name: keyVaultName
|
||||
displayName: Key Vault Name
|
||||
type: string
|
||||
default: '<your-key-vault-name>'
|
||||
- name: sqlServerName
|
||||
displayName: Sql Server Name
|
||||
type: string
|
||||
default: '<your-sql-server-name>'
|
||||
- name: sqlDataWarehouseName
|
||||
displayName: Sql Data Warehouse Name
|
||||
type: string
|
||||
default: '<your-sql-dw-name>'
|
||||
- name: azureResourceManagerConnectionName
|
||||
displayName: Azure Resource Manager Connection Name
|
||||
type: string
|
||||
default: '<your-azure-resource-manager-connection-name>'
|
||||
|
||||
stages:
|
||||
- stage: ReplaceValues
|
||||
displayName: 'Replace Values in ARM parameters files'
|
||||
jobs:
|
||||
- job: ReplaceValues
|
||||
displayName: 'Replace Values in ARM parameters files'
|
||||
continueOnError: false
|
||||
pool:
|
||||
vmImage: 'ubuntu-latest'
|
||||
|
||||
steps:
|
||||
# Create repository fork
|
||||
- task: PowerShell@2
|
||||
name: create_repository_fork
|
||||
displayName: Create repository fork
|
||||
enabled: true
|
||||
continueOnError: false
|
||||
inputs:
|
||||
targetType: 'filePath'
|
||||
filePath: '$(System.DefaultWorkingDirectory)/code/ForkDevOps.ps1'
|
||||
errorActionPreference: 'stop'
|
||||
failOnStderr: false
|
||||
ignoreLASTEXITCODE: false
|
||||
pwsh: true
|
||||
arguments: >
|
||||
-OrgName "${{ parameters.devOpsOrgName }}"
|
||||
-SourceProjectName "${{ parameters.sourceProjectName }}"
|
||||
-SourceRepositoryName "${{ parameters.sourceRepositoryName }}"
|
||||
-DestinationProjectName "${{ parameters.destinationProjectName }}"
|
||||
-DestinationRepositoryName "${{ parameters.destinationRepositoryName }}"
|
||||
-PatToken "${{ parameters.devOpsPatToken }}"
|
||||
|
||||
# Checkout code
|
||||
- checkout: 'git://${{ parameters.destinationProjectName }}/${{ parameters.destinationRepositoryName }}'
|
||||
name: checkout_repository
|
||||
displayName: 'Checkout repository'
|
||||
submodules: true
|
||||
lfs: false
|
||||
clean: true
|
||||
continueOnError: false
|
||||
enabled: true
|
||||
|
||||
# Replace values in key vault 001
|
||||
- task: PowerShell@2
|
||||
name: key_vault_001_parameter_replacement
|
||||
displayName: Key vault parameter replacement
|
||||
enabled: true
|
||||
continueOnError: false
|
||||
inputs:
|
||||
targetType: 'filePath'
|
||||
filePath: '$(System.DefaultWorkingDirectory)/code/UpdateWorkflowFile.ps1'
|
||||
errorActionPreference: 'stop'
|
||||
failOnStderr: false
|
||||
ignoreLASTEXITCODE: false
|
||||
pwsh: true
|
||||
arguments: >
|
||||
-FilePath "$(System.DefaultWorkingDirectory)/infra/KeyVault/params.keyVault001.json"
|
||||
-location "${{ parameters.locationId }}"
|
||||
-keyVaultName "${{ parameters.keyVaultName }}"
|
||||
-subnetId "/subscriptions/${{ parameters.subscriptionId }}/resourceGroups/${{ parameters.vnetResourceGroupName }}/providers/Microsoft.Network/virtualNetworks/${{ parameters.vnetName }}/subnets/${{ parameters.privateLinkSubnetName }}"
|
||||
|
||||
# Replace values in databricks 001
|
||||
- task: PowerShell@2
|
||||
name: databricks_001_parameter_replacement
|
||||
displayName: Databricks parameter replacement
|
||||
enabled: true
|
||||
continueOnError: false
|
||||
inputs:
|
||||
targetType: 'filePath'
|
||||
filePath: '$(System.DefaultWorkingDirectory)/code/UpdateWorkflowFile.ps1'
|
||||
errorActionPreference: 'stop'
|
||||
failOnStderr: false
|
||||
ignoreLASTEXITCODE: false
|
||||
pwsh: true
|
||||
arguments: >
|
||||
-FilePath "$(System.DefaultWorkingDirectory)/infra/Databricks/params.databricks001.json"
|
||||
-location "${{ parameters.locationId }}"
|
||||
-databricksName "${{ parameters.databricksName }}"
|
||||
-databricksVnetId "/subscriptions/${{ parameters.subscriptionId }}/resourceGroups/${{ parameters.vnetResourceGroupName }}/providers/Microsoft.Network/virtualNetworks/${{ parameters.vnetName }}"
|
||||
-databricksManagedResourceGroupId "/subscriptions/${{ parameters.subscriptionId }}/resourceGroups/${{ parameters.databricksResourceGroupName }}"
|
||||
-databricksPrivateSubnetName "${{ parameters.databricksPrivateSubnetName }}"
|
||||
-databricksPublicSubnetName "${{ parameters.databricksPublicSubnetName }}"
|
||||
|
||||
# Replace values in sql server 001
|
||||
- task: PowerShell@2
|
||||
name: sql_server_001_parameter_replacement
|
||||
displayName: Sql server parameter replacement
|
||||
enabled: true
|
||||
continueOnError: false
|
||||
inputs:
|
||||
targetType: 'filePath'
|
||||
filePath: '$(System.DefaultWorkingDirectory)/code/UpdateWorkflowFile.ps1'
|
||||
errorActionPreference: 'stop'
|
||||
failOnStderr: false
|
||||
ignoreLASTEXITCODE: false
|
||||
pwsh: true
|
||||
arguments: >
|
||||
-FilePath "$(System.DefaultWorkingDirectory)/infra/SqlServer/params.sqlServer001.json"
|
||||
-location "${{ parameters.locationId }}"
|
||||
-sqlServerName "${{ parameters.sqlServerName }}"
|
||||
-subnetId "/subscriptions/${{ parameters.subscriptionId }}/resourceGroups/${{ parameters.vnetResourceGroupName }}/providers/Microsoft.Network/virtualNetworks/${{ parameters.vnetName }}/subnets/${{ parameters.privateLinkSubnetName }}"
|
||||
|
||||
# Replace values in data warehouse 001
|
||||
- task: PowerShell@2
|
||||
name: data_warehouse_001_parameter_replacement
|
||||
displayName: Data warehouse parameter replacement
|
||||
enabled: true
|
||||
continueOnError: false
|
||||
inputs:
|
||||
targetType: 'filePath'
|
||||
filePath: '$(System.DefaultWorkingDirectory)/code/UpdateWorkflowFile.ps1'
|
||||
errorActionPreference: 'stop'
|
||||
failOnStderr: false
|
||||
ignoreLASTEXITCODE: false
|
||||
pwsh: true
|
||||
arguments: >
|
||||
-FilePath "$(System.DefaultWorkingDirectory)/infra/SqlDataWarehouse/params.sqlDataWarehouse001.json"
|
||||
-location "${{ parameters.locationId }}"
|
||||
-sqlServerId "/subscriptions/${{ parameters.subscriptionId }}/resourceGroups/${{ parameters.resourceGroupName }}/providers/Microsoft.Sql/servers/${{ parameters.sqlServerName }}"
|
||||
-sqlServerAdministratorLoginPassword "$(password)"
|
||||
-sqlDataWarehouseName "${{ parameters.sqlDataWarehouseName }}"
|
||||
-keyVaultId "/subscriptions/${{ parameters.subscriptionId }}/resourceGroups/${{ parameters.resourceGroupName }}/providers/Microsoft.KeyVault/vaults/${{ parameters.keyVaultName }}"
|
||||
|
||||
# Replace values in data factory 001
|
||||
- task: PowerShell@2
|
||||
name: data_factory_001_parameter_replacement
|
||||
displayName: Data factory parameter replacement
|
||||
enabled: true
|
||||
continueOnError: false
|
||||
inputs:
|
||||
targetType: 'filePath'
|
||||
filePath: '$(System.DefaultWorkingDirectory)/code/UpdateWorkflowFile.ps1'
|
||||
errorActionPreference: 'stop'
|
||||
failOnStderr: false
|
||||
ignoreLASTEXITCODE: false
|
||||
pwsh: true
|
||||
arguments: >
|
||||
-FilePath "$(System.DefaultWorkingDirectory)/infra/DataFactory/params.dataFactory001.json"
|
||||
-location "${{ parameters.locationId }}"
|
||||
-dataFactoryName "${{ parameters.dataFactoryName }}"
|
||||
-keyVaultId "/subscriptions/${{ parameters.subscriptionId }}/resourceGroups/${{ parameters.resourceGroupName }}/providers/Microsoft.KeyVault/vaults/${{ parameters.keyVaultName }}"
|
||||
-subnetId "/subscriptions/${{ parameters.subscriptionId }}/resourceGroups/${{ parameters.vnetResourceGroupName }}/providers/Microsoft.Network/virtualNetworks/${{ parameters.vnetName }}/subnets/${{ parameters.privateLinkSubnetName }}"
|
||||
|
||||
# Replace values in data factory 001
|
||||
- task: PowerShell@2
|
||||
name: data_factory_001_parameter_replacement
|
||||
displayName: Data factory parameter replacement
|
||||
enabled: true
|
||||
continueOnError: false
|
||||
inputs:
|
||||
targetType: 'filePath'
|
||||
filePath: '$(System.DefaultWorkingDirectory)/code/UpdateWorkflowFile.ps1'
|
||||
errorActionPreference: 'stop'
|
||||
failOnStderr: false
|
||||
ignoreLASTEXITCODE: false
|
||||
pwsh: true
|
||||
arguments: >
|
||||
-FilePath "$(System.DefaultWorkingDirectory)/infra/DataFactory/params.dataFactory001.json"
|
||||
-location "${{ parameters.locationId }}"
|
||||
-synapseWorkspaceName ""
|
||||
-storageContainerId ""
|
||||
-datalakeAnalyticsResourceId ""
|
||||
-computeSubnetResourceId ""
|
||||
|
||||
# Replace values in data deployment yml
|
||||
- task: PowerShell@2
|
||||
name: data_domain_variable_replacement
|
||||
displayName: Data Domain Deployment variable replacement
|
||||
enabled: true
|
||||
continueOnError: false
|
||||
inputs:
|
||||
targetType: 'filePath'
|
||||
filePath: '$(System.DefaultWorkingDirectory)/code/UpdateWorkflowFile.ps1'
|
||||
errorActionPreference: 'stop'
|
||||
failOnStderr: false
|
||||
ignoreLASTEXITCODE: false
|
||||
pwsh: true
|
||||
arguments: >
|
||||
-FilePath "$(System.DefaultWorkingDirectory)/.ado/workflows/dataDomainDeployment.yml"
|
||||
-AZURE_RESOURCE_MANAGER_CONNECTION_NAME "${{ parameters.azureResourceManagerConnectionName }}"
|
||||
-AZURE_SUBSCRIPTION_ID "${{ parameters.subscriptionId }}"
|
||||
-AZURE_RESOURCE_GROUP_NAME "${{ parameters.resourceGroupName }}"
|
||||
-AZURE_LOCATION "${{ parameters.location }}"
|
||||
|
||||
- publish: '$(System.DefaultWorkingDirectory)'
|
||||
artifact: 'output'
|
||||
|
||||
# Push changes to new node
|
||||
- bash: |
|
||||
echo "Removing unnecessary files"
|
||||
rm -f "$(System.DefaultWorkingDirectory)/code/ForkDevOps.ps1"
|
||||
rm -f "$(System.DefaultWorkingDirectory)/code/UpdateParameterFile.ps1"
|
||||
rm -f "$(System.DefaultWorkingDirectory)/code/UpdateWorkflowFile.ps1"
|
||||
|
||||
echo "Configure git"
|
||||
git config --local user.email "mabuss@microsoft.com"
|
||||
git config --local user.name "GitHub Data Node Template"
|
||||
|
||||
echo "Push changes to remote repository"
|
||||
git add .
|
||||
git commit -m "Updated parameters" -a
|
||||
MY_PAT=${{ parameters.devOpsPatToken }}
|
||||
B64_PAT=$(echo ":$MY_PAT" | base64)
|
||||
git -c http.extraHeader="Authorization: Basic ${B64_PAT}" push https://dev.azure.com/${{ parameters.devOpsOrgName }}/${{ parameters.destinationProjectName }}/_git/${{ parameters.destinationRepositoryName }}
|
||||
name: push_changes
|
||||
displayName: Push changes
|
||||
enabled: true
|
||||
continueOnError: false
|
|
@ -0,0 +1,51 @@
|
|||
name: Update Parameters
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
paths:
|
||||
- "config/**"
|
||||
- ".github/workflows/updateParameters.yml"
|
||||
|
||||
env:
|
||||
MANAGEMENT_SUBSCRIPTION_ID: "4060c03e-0d2e-44b7-82a3-da9376fe50b2"
|
||||
GLOBAL_DNS_RG_NAME: "dh-global-dns"
|
||||
DATA_LANDING_ZONE_SUBSCRIPTION_ID: ""
|
||||
DATA_LANDING_ZONE_NAME: ""
|
||||
LOCATION: "northeurope"
|
||||
SUBNET_ID: ""
|
||||
SYNAPSE_STORAGE_ACCOUNT_NAME: ""
|
||||
SYNAPSE_STORAGE_ACCOUNT_FILE_SYSTEM_NAME: ""
|
||||
AZURE_RESOURCE_MANAGER_CONNECTION_NAME: ""
|
||||
|
||||
jobs:
|
||||
renaming:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
||||
- name: Check Out Repository
|
||||
id: checkout_repository
|
||||
uses: actions/checkout@v2
|
||||
|
||||
# Update Parameters
|
||||
- name: Update Parameters
|
||||
id: generate_password_001
|
||||
run: |
|
||||
echo "Updating Parameters"
|
||||
pwsh $GITHUB_WORKSPACE/config/UpdateParameters.ps1 `
|
||||
-ManagementSubscriptionId ${{ env.MANAGEMENT_SUBSCRIPTION_ID }} `
|
||||
-GlobalDnsRgName ${{ env.GLOBAL_DNS_RG_NAME }} `
|
||||
-DataLandingZoneSubscriptionId ${{ env.DATA_LANDING_ZONE_SUBSCRIPTION_ID }} `
|
||||
-DataLandingZoneName ${{ env.DATA_LANDING_ZONE_NAME }} `
|
||||
-Location ${{ env.LOCATION }} `
|
||||
-SubnetId ${{ env.SUBNET_ID }} `
|
||||
-SynapseStorageAccountName ${{ env.SYNAPSE_STORAGE_ACCOUNT_NAME }} `
|
||||
-SynapseStorageAccountFileSystemName ${{ env.SYNAPSE_STORAGE_ACCOUNT_FILE_SYSTEM_NAME }} `
|
||||
-AzureResourceManagerConnectionName ${{ env.AZURE_RESOURCE_MANAGER_CONNECTION_NAME }} `
|
||||
|
||||
# Create Artifact
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: updated-parameters
|
||||
path: ${{ github.workspace }}
|
|
@ -1,205 +0,0 @@
|
|||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$OrgName,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$SourceProjectName,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$SourceRepositoryName,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$DestinationProjectName,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$DestinationRepositoryName,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$PatToken,
|
||||
|
||||
[Parameter(Position = 1, ValueFromRemainingArguments)]
|
||||
$Remaining
|
||||
)
|
||||
|
||||
function Invoke-DevOpsApiRequest {
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$PatToken,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$RestMethod,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$UriExtension,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$Body
|
||||
)
|
||||
# Defining authentitaction header
|
||||
Write-Verbose "Defining authentication header"
|
||||
$authenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($PatToken)")) }
|
||||
|
||||
# Define base uri
|
||||
Write-Verbose "Defining base uri"
|
||||
$baseUri = "https://dev.azure.com/"
|
||||
$basePparameters = "api-version=6.0"
|
||||
|
||||
# Create uri
|
||||
Write-Verbose "Creating uri"
|
||||
$parameters = "${basePparameters}"
|
||||
$uri = "${baseUri}${UriExtension}?${parameters}"
|
||||
Write-Host $uri
|
||||
|
||||
# Call REST API
|
||||
Write-Verbose "Calling REST API"
|
||||
$result = Invoke-RestMethod -Uri $uri -Method $RestMethod -Headers $authenicationHeader -Body $Body -ContentType "application/json"
|
||||
return $result
|
||||
}
|
||||
|
||||
|
||||
function Get-ProjectId {
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$ProjectName,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$PatToken,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$OrgName
|
||||
)
|
||||
# Define uri extension
|
||||
Write-Verbose "Defining uri extension"
|
||||
$uriExtension = "${OrgName}/_apis/projects"
|
||||
|
||||
# Define body
|
||||
Write-Verbose "Defining body"
|
||||
$body = @{} | ConvertTo-Json -Depth 5
|
||||
|
||||
# Call rest api
|
||||
Write-Verbose "Calling REST API"
|
||||
$result = Invoke-DevOpsApiRequest -PatToken $PatToken -RestMethod Get -UriExtension $uriExtension -Body $body
|
||||
|
||||
# Iterate through projects and return id
|
||||
Write-Verbose "Iterating through projects and returning id"
|
||||
foreach ($project in $result.value) {
|
||||
if ($project.name -eq $ProjectName) {
|
||||
return $project.id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function Get-RepositoryId {
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$RepositoryName,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$ProjectId,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$PatToken,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$OrgName
|
||||
)
|
||||
# Define uri extension
|
||||
Write-Verbose "Defining uri extension"
|
||||
$uriExtension = "${OrgName}/${ProjectId}/_apis/git/repositories"
|
||||
|
||||
# Define body
|
||||
Write-Verbose "Defining body"
|
||||
$body = @{} | ConvertTo-Json -Depth 5
|
||||
|
||||
# Call rest api
|
||||
Write-Verbose "Calling REST API"
|
||||
$result = Invoke-DevOpsApiRequest -PatToken $PatToken -RestMethod Get -UriExtension $uriExtension -Body $body
|
||||
|
||||
# Iterate through repositories and return id
|
||||
Write-Verbose "Iterating through repositories and returning id"
|
||||
foreach ($repository in $result.value) {
|
||||
if ($repository.name -eq $RepositoryName) {
|
||||
return $repository.id
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Add-Fork {
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$SourceRepositoryId,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$SourceProjectId,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$DestinationRepositoryName,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$DestinationProjectId,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$PatToken,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$OrgName
|
||||
)
|
||||
# Define uri extension
|
||||
Write-Verbose "Defining uri extension"
|
||||
$uriExtension = "${OrgName}/_apis/git/repositories"
|
||||
|
||||
# Define body
|
||||
Write-Verbose "Defining body"
|
||||
$body = @{
|
||||
"name" = $DestinationRepositoryName
|
||||
"project" = @{
|
||||
"id" = $DestinationProjectId
|
||||
}
|
||||
"parentRepository" = @{
|
||||
"id" = $SourceRepositoryId
|
||||
"project" = @{
|
||||
"id" = $SourceProjectId
|
||||
}
|
||||
}
|
||||
} | ConvertTo-Json -Depth 5
|
||||
|
||||
# Call rest api
|
||||
Write-Verbose "Calling REST API"
|
||||
$result = Invoke-DevOpsApiRequest -PatToken $PatToken -RestMethod Post -UriExtension $uriExtension -Body $body
|
||||
return $result
|
||||
}
|
||||
|
||||
# Get project and repository id's
|
||||
Write-Verbose "Getting project and repository id's"
|
||||
$sourceProjectId = Get-ProjectId -ProjectName $SourceProjectName -PatToken $PatToken -OrgName $OrgName
|
||||
$destinationProjectId = Get-ProjectId -ProjectName $DestinationProjectName -PatToken $PatToken -OrgName $OrgName
|
||||
$sourceRepositoryId = Get-RepositoryId -RepositoryName $SourceRepositoryName -ProjectId $sourceProjectId -PatToken $PatToken -OrgName $OrgName
|
||||
|
||||
# Fork repository
|
||||
Write-Verbose "Forking repository"
|
||||
$result = Add-Fork -SourceRepositoryId $repositoryId -SourceProjectId $projectId -DestinationProjectId $projectId -DestinationRepositoryName "fork-test001" -PatToken $PatToken -OrgName $OrgName
|
||||
Write-Verbose $result
|
|
@ -1,25 +0,0 @@
|
|||
# Define script arguments
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$FilePath,
|
||||
|
||||
[Parameter(Position=1, ValueFromRemainingArguments)]
|
||||
$Remaining
|
||||
)
|
||||
|
||||
# Load json file
|
||||
Write-Host "Loading JSON file"
|
||||
$JsonContent = Get-Content -Path $FilePath -Raw | Out-String | ConvertFrom-Json
|
||||
|
||||
for ($i = 0; $i -lt $Remaining.Count; $i=$i+2)
|
||||
{
|
||||
Write-Host "${ParameterName}: ${ParameterValue}"
|
||||
$ParameterName = $Remaining[$i].Substring(1)
|
||||
$ParameterValue = $Remaining[$i+1]
|
||||
$JsonContent.parameters.$ParameterName.value = $ParameterValue
|
||||
}
|
||||
|
||||
# Write json file
|
||||
Write-Host "Writing JSON file"
|
||||
$JsonContent | ConvertTo-Json -Depth 64 | Set-Content $FilePath
|
|
@ -1,29 +0,0 @@
|
|||
# Define script arguments
|
||||
param (
|
||||
[Parameter(Mandatory = $true)]
|
||||
[String]
|
||||
$FilePath,
|
||||
|
||||
[Parameter(Position=1, ValueFromRemainingArguments)]
|
||||
$Remaining
|
||||
)
|
||||
|
||||
# Install YAML pwsh module
|
||||
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
|
||||
Install-Module -Name powershell-yaml
|
||||
|
||||
# Load json file
|
||||
Write-Host "Loading YAML file"
|
||||
$YamlContent = Get-Content -Path $FilePath -Raw | Out-String | ConvertFrom-Yaml -Ordered
|
||||
|
||||
for ($i = 0; $i -lt $Remaining.Count; $i=$i+2)
|
||||
{
|
||||
Write-Host "${ParameterName}: ${ParameterValue}"
|
||||
$ParameterName = $Remaining[$i].Substring(1)
|
||||
$ParameterValue = $Remaining[$i+1]
|
||||
$YamlContent.variables[$ParameterName] = $ParameterValue
|
||||
}
|
||||
|
||||
# Write json file
|
||||
Write-Host "Writing YAML file"
|
||||
$YamlContent | ConvertTo-Yaml | Set-Content $FilePath
|
|
@ -0,0 +1,116 @@
|
|||
[CmdletBinding()]
|
||||
Param(
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$ManagementSubscriptionId,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$GlobalDnsRgName,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$DataLandingZoneSubscriptionId,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$DataLandingZoneName,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$Location,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$SubnetId,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$SynapseStorageAccountName,
|
||||
|
||||
[Parameter(Mandatory)]
|
||||
[ValidateNotNullOrEmpty()]
|
||||
[string]
|
||||
$SynapseStorageAccountFileSystemName,
|
||||
|
||||
[Parameter(Mandatory=$false)]
|
||||
[Switch]
|
||||
$AzureResourceManagerConnectionName
|
||||
)
|
||||
|
||||
function SetValue($Object, $Key, $Value) {
|
||||
$p1, $p2 = $Key.Split(".")
|
||||
if ($p2) {
|
||||
SetValue -object $Object.$p1 -key $p2 -Value $Value
|
||||
}
|
||||
else {
|
||||
$Object.$p1 = $Value
|
||||
}
|
||||
}
|
||||
|
||||
# Loading Configuration File for Parameter Updates
|
||||
Write-Host "Loading Configuration File for Parameter Updates"
|
||||
$configs = Get-Content -Path "config.json" -Raw | Out-String | ConvertFrom-Json
|
||||
|
||||
foreach ($config in $configs) {
|
||||
# Get Replacement Key-Value Pairs
|
||||
Write-Host "Getting Replacement Key-Value Pairs"
|
||||
$parameterReplacements = @{}
|
||||
$config.parameters.psobject.properties | ForEach-Object { $parameterReplacements[$_.Name] = $_.Value }
|
||||
|
||||
if ($config.fileType.ToLower() -eq "json") {
|
||||
# Load ARM Parameter File
|
||||
Write-Host "Loading ARM Parameter File"
|
||||
$parameterFile = Get-Content -Path $config.filePath -Raw | Out-String | ConvertFrom-Json
|
||||
|
||||
# Replace Parameter Values
|
||||
Write-Host "Replacing Parameter Values"
|
||||
foreach ( $parameterReplacementPair in $parameterReplacements.GetEnumerator() ) {
|
||||
$key = $parameterReplacementPair.Key
|
||||
$value = $parameterReplacementPair.Value
|
||||
$value = $ExecutionContext.InvokeCommand.ExpandString($value)
|
||||
|
||||
# Replace Parameter
|
||||
Write-Host "Replacing Parameter '${key}' with Value '${value}'"
|
||||
SetValue -Object $parameterFile -Key $key -Value $value
|
||||
}
|
||||
|
||||
# Set Content of Parameter File
|
||||
Write-Host "Setting Content of Parameter File"
|
||||
$parameterFile | ConvertTo-Json | Set-Content -Path $config.filePath
|
||||
}
|
||||
elseif (($config.fileType.ToLower() -eq "yaml") -or ($config.fileType.ToLower() -eq "yml")) {
|
||||
# Load YAML Deployment File
|
||||
Write-Host "Loading YAML Deployment File"
|
||||
$parameterFile = Get-Content -Path $config.filePath -Raw | Out-String | ConvertFrom-Yaml -Ordered
|
||||
|
||||
# Replace Variables
|
||||
Write-Host "Replacing Variables"
|
||||
foreach ( $parameterReplacementPair in $parameterReplacements.GetEnumerator() ) {
|
||||
$key = $parameterReplacementPair.Key
|
||||
$value = $parameterReplacementPair.Value
|
||||
$value = $ExecutionContext.InvokeCommand.ExpandString($value)
|
||||
|
||||
# Replace Parameter
|
||||
Write-Host "Replacing Parameter '${key}' with Value '${value}'"
|
||||
SetValue -Object $parameterFile -Key $key -Value $value
|
||||
}
|
||||
|
||||
# Set Content of Parameter File
|
||||
Write-Host "Setting Content of Parameter File"
|
||||
$parameterFile | ConvertTo-Yaml | Set-Content -Path $config.filePath
|
||||
}
|
||||
else {
|
||||
Write-Error "File Type not Supported"
|
||||
throw "File Type not Supported"
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,135 @@
|
|||
[
|
||||
{
|
||||
"filePath": "infra/BigDataPool/params.bigDataPool001.json",
|
||||
"fileType": "json",
|
||||
"parameters": {
|
||||
"parameters.location.value": "${Location}",
|
||||
"parameters.synapseWorkspaceId.value": "/subscriptions/${DataLandingZoneSubscriptionId}/resourceGroups/${DataLandingZoneName}-rg/providers/Microsoft.Synapse/workspaces/${DataLandingZoneName}-synapse001"
|
||||
}
|
||||
},
|
||||
{
|
||||
"filePath": "infra/CosmosDb/params.cosmosDb001.json",
|
||||
"fileType": "json",
|
||||
"parameters": {
|
||||
"parameters.location.value": "${Location}",
|
||||
"parameters.cosmosAccountName.value": "${DataLandingZoneName}-cosmos001",
|
||||
"parameters.keyVaultId.value": "/subscriptions/${DataLandingZoneSubscriptionId}/resourceGroups/${DataLandingZoneName}-rg/providers/Microsoft.KeyVault/vaults/${DataLandingZoneName}-keyvault001",
|
||||
"parameters.subnetId.value": "${SubnetId}",
|
||||
"parameters.privateDnsZoneId.value": "/subscriptions/${ManagementSubscriptionId}/resourceGroups/${GlobalDnsRgName}/providers/Microsoft.Network/privateDnsZones/privatelink.documents.azure.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"filePath": "infra/DataFactory/params.dataFactory001.json",
|
||||
"fileType": "json",
|
||||
"parameters": {
|
||||
"parameters.location.value": "${Location}",
|
||||
"parameters.dataFactoryName.value": "${DataLandingZoneName}-datafactory001",
|
||||
"parameters.keyVaultId.value": "/subscriptions/${DataLandingZoneSubscriptionId}/resourceGroups/${DataLandingZoneName}-rg/providers/Microsoft.KeyVault/vaults/${DataLandingZoneName}-keyvault001",
|
||||
"parameters.subnetId.value": "${SubnetId}",
|
||||
"parameters.privateDnsZoneIdDataFactory.value": "/subscriptions/${ManagementSubscriptionId}/resourceGroups/${GlobalDnsRgName}/providers/Microsoft.Network/privateDnsZones/privatelink.datafactory.azure.net",
|
||||
"parameters.privateDnsZoneIdPortal.value": "/subscriptions/${ManagementSubscriptionId}/resourceGroups/${GlobalDnsRgName}/providers/Microsoft.Network/privateDnsZones/privatelink.azure.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"filePath": "infra/KeyVault/params.keyVault001.json",
|
||||
"fileType": "json",
|
||||
"parameters": {
|
||||
"parameters.location.value": "${Location}",
|
||||
"parameters.keyVaultName.value": "${DataLandingZoneName}-keyvault001",
|
||||
"parameters.subnetId.value": "${SubnetId}",
|
||||
"parameters.privateDnsZoneId.value": "/subscriptions/${ManagementSubscriptionId}/resourceGroups/${GlobalDnsRgName}/providers/Microsoft.Network/privateDnsZones/privatelink.vaultcore.azure.net"
|
||||
}
|
||||
},
|
||||
{
|
||||
"filePath": "infra/MariaDb/params.mariaDb001.json",
|
||||
"fileType": "json",
|
||||
"parameters": {
|
||||
"parameters.location.value": "${Location}",
|
||||
"parameters.mariaDbServerName.value": "${DataLandingZoneName}-mariadbserver001",
|
||||
"parameters.keyVaultId.value": "/subscriptions/${DataLandingZoneSubscriptionId}/resourceGroups/${DataLandingZoneName}-rg/providers/Microsoft.KeyVault/vaults/${DataLandingZoneName}-keyvault001",
|
||||
"parameters.subnetId.value": "${SubnetId}",
|
||||
"parameters.privateDnsZoneId.value": "/subscriptions/${ManagementSubscriptionId}/resourceGroups/${GlobalDnsRgName}/providers/Microsoft.Network/privateDnsZones/privatelink.mariadb.database.azure.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"filePath": "infra/MySql/params.mySql001.json",
|
||||
"fileType": "json",
|
||||
"parameters": {
|
||||
"parameters.location.value": "${Location}",
|
||||
"parameters.mySqlServerName.value": "${DataLandingZoneName}-mysqlserver001",
|
||||
"parameters.keyVaultId.value": "/subscriptions/${DataLandingZoneSubscriptionId}/resourceGroups/${DataLandingZoneName}-rg/providers/Microsoft.KeyVault/vaults/${DataLandingZoneName}-keyvault001",
|
||||
"parameters.subnetId.value": "${SubnetId}",
|
||||
"parameters.privateDnsZoneId.value": "/subscriptions/${ManagementSubscriptionId}/resourceGroups/${GlobalDnsRgName}/providers/Microsoft.Network/privateDnsZones/privatelink.mysql.database.azure.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"filePath": "infra/PostgreSql/params.postgreSql001.json",
|
||||
"fileType": "json",
|
||||
"parameters": {
|
||||
"parameters.location.value": "${Location}",
|
||||
"parameters.postgreSqlServerName.value": "${DataLandingZoneName}-postgresqlserver001",
|
||||
"parameters.keyVaultId.value": "/subscriptions/${DataLandingZoneSubscriptionId}/resourceGroups/${DataLandingZoneName}-rg/providers/Microsoft.KeyVault/vaults/${DataLandingZoneName}-keyvault001",
|
||||
"parameters.subnetId.value": "${SubnetId}",
|
||||
"parameters.privateDnsZoneId.value": "/subscriptions/${ManagementSubscriptionId}/resourceGroups/${GlobalDnsRgName}/providers/Microsoft.Network/privateDnsZones/privatelink.postgres.database.azure.com"
|
||||
}
|
||||
},
|
||||
{
|
||||
"filePath": "infra/SqlDatabase/params.sqlDatabase001.json",
|
||||
"fileType": "json",
|
||||
"parameters": {
|
||||
"parameters.location.value": "${Location}",
|
||||
"parameters.sqlServerId.value": "/subscriptions/${DataLandingZoneSubscriptionId}/resourceGroups/${DataLandingZoneName}-rg/providers/Microsoft.Sql/servers/${DataLandingZoneName}-sqlserver001",
|
||||
"parameters.keyVaultId.value": "/subscriptions/${DataLandingZoneSubscriptionId}/resourceGroups/${DataLandingZoneName}-rg/providers/Microsoft.KeyVault/vaults/${DataLandingZoneName}-keyvault001"
|
||||
}
|
||||
},
|
||||
{
|
||||
"filePath": "infra/SqlPool/params.sqlPool001.json",
|
||||
"fileType": "json",
|
||||
"parameters": {
|
||||
"parameters.location.value": "${Location}",
|
||||
"parameters.synapseWorkspaceId.value": "/subscriptions/${DataLandingZoneSubscriptionId}/resourceGroups/${DataLandingZoneName}-rg/providers/Microsoft.Synapse/workspaces/${DataLandingZoneName}-synapse001"
|
||||
}
|
||||
},
|
||||
{
|
||||
"filePath": "infra/SqlServer/params.sqlServer001.json",
|
||||
"fileType": "json",
|
||||
"parameters": {
|
||||
"parameters.location.value": "${Location}",
|
||||
"parameters.sqlServerName.value": "${DataLandingZoneName}-sqlserver001",
|
||||
"parameters.subnetId.value": "${SubnetId}",
|
||||
"parameters.privateDnsZoneId.value": "/subscriptions/${ManagementSubscriptionId}/resourceGroups/${GlobalDnsRgName}/providers/Microsoft.Network/privateDnsZones/privatelink.database.windows.net"
|
||||
}
|
||||
},
|
||||
{
|
||||
"filePath": "infra/Synapse/params.synapse001.json",
|
||||
"fileType": "json",
|
||||
"parameters": {
|
||||
"parameters.location.value": "${Location}",
|
||||
"parameters.synapseWorkspaceName.value": "${DataLandingZoneName}-synapse001",
|
||||
"parameters.synapseDefaultStorageAccountName.value": "${SynapseStorageAccountName}",
|
||||
"parameters.synapseDefaultStorageAccountFileSystem.value": "${SynapseStorageAccountFileSystemName}",
|
||||
"parameters.subnetId.value": "${SubnetId}",
|
||||
"parameters.privateDnsZoneIdSql.value": "/subscriptions/${ManagementSubscriptionId}/resourceGroups/${GlobalDnsRgName}/providers/Microsoft.Network/privateDnsZones/privatelink.sql.azuresynapse.net",
|
||||
"parameters.privateDnsZoneIdDev.value": "/subscriptions/${ManagementSubscriptionId}/resourceGroups/${GlobalDnsRgName}/providers/Microsoft.Network/privateDnsZones/privatelink.dev.azuresynapse.net"
|
||||
}
|
||||
},
|
||||
{
|
||||
"filePath": ".ado/workflows/dataDomainDeployment.yml",
|
||||
"fileType": "yaml",
|
||||
"parameters": {
|
||||
"variables.AZURE_RESOURCE_MANAGER_CONNECTION_NAME": "${AzureResourceManagerConnectionName}",
|
||||
"variables.AZURE_SUBSCRIPTION_ID": "${DataLandingZoneSubscriptionId}",
|
||||
"variables.AZURE_RESOURCE_GROUP_NAME": "${DataLandingZoneName}-rg",
|
||||
"variables.AZURE_LOCATION": "${Location}"
|
||||
}
|
||||
},
|
||||
{
|
||||
"filePath": ".github/workflows/dataDomainDeployment.yml",
|
||||
"fileType": "yaml",
|
||||
"parameters": {
|
||||
"env.AZURE_SUBSCRIPTION_ID": "${DataLandingZoneSubscriptionId}",
|
||||
"env.AZURE_RESOURCE_GROUP_NAME": "${DataLandingZoneName}-rg",
|
||||
"env.AZURE_LOCATION": "${Location}"
|
||||
}
|
||||
}
|
||||
]
|
Загрузка…
Ссылка в новой задаче