Skip to content

Commit b5499f4

Browse files
committed
Write the runsettings output from the ARM script into a file so that the integration tests can use it
1 parent 1d675a1 commit b5499f4

File tree

2 files changed

+66
-6
lines changed

2 files changed

+66
-6
lines changed

.github/workflows/test_azure_devtest_labs_integration.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ jobs:
7474
id: create-devtest-labs-environment
7575
uses: azure/CLI@v1
7676
with:
77-
#azcliversion: 2.24.0 # Versions prior to this have a bug creating environments
77+
# azcliversion: 2.24.0 # Versions prior to this have a bug creating environments
78+
# This runs in a container, so all output is passed back using 'echo "::set-output name=OUTPUT_VAR_NAME::value here"', as files created won't persist.
7879
inlineScript: |
7980
echo "========================================================================================================================================================================================================"
8081
echo "Azure CLI Version: $(az version | jq '."azure-cli"')"
@@ -162,6 +163,7 @@ jobs:
162163
echo "::set-output name=FUNCTIONS_APP_URI::$(echo $DEPLOYMENTOUTPUT | jq --raw-output '.functionsAppUri.value')"
163164
echo "::set-output name=KEY_VAULT_NAME::$(echo $DEPLOYMENTOUTPUT | jq --raw-output '.keyVaultName.value')"
164165
echo "::set-output name=FUNCTIONS_APP_KEY::$(echo $DEPLOYMENTOUTPUT | jq --raw-output '.functionsAppKey.value')"
166+
echo "::set-output name=RUN_SETTINGS::$(echo $DEPLOYMENTOUTPUT | jq --raw-output '.runSettings.value')"
165167
166168
echo "========================================================================================================================================================================================================"
167169
@@ -178,6 +180,14 @@ jobs:
178180
echo "STORAGE_ACCOUNTCONNECTION_STRING: ${{ steps.create-devtest-labs-environment.outputs.STORAGE_ACCOUNTCONNECTION_STRING }}"
179181
echo "STORAGE_ACCOUNT_NAME: ${{ steps.create-devtest-labs-environment.outputs.STORAGE_ACCOUNT_NAME }}"
180182
echo "KEY_VAULT_NAME: ${{ steps.create-devtest-labs-environment.outputs.KEY_VAULT_NAME }}"
183+
echo "RUN_SETTINGS: ${{ steps.create-devtest-labs-environment.outputs.RUN_SETTINGS }}"
184+
185+
186+
# Write the runsettings output from the ARM script into a file so that the integration tests can use it
187+
- name: Show create environment outputs
188+
run: |
189+
echo "${{ steps.create-devtest-labs-environment.outputs.RUN_SETTINGS }}" > ./integrationTest.runsettings
190+
181191
# echo "ENVIRONMENT_INSTANCE_RESOURCES: ${{ steps.get-devtest-labs-environment-resources.outputs.ENVIRONMENT_INSTANCE_RESOURCES }}"
182192
# az lab arm-template show --resource-group $RESOURCE_GROUP
183193

Azure-DevTestLab/Environments/sqlcollaborative_AzureDataPipelineTools/azuredeploy.json

Lines changed: 55 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@
5151

5252
"keyVaultApiVersion": "2021-04-01-preview",
5353
"keyVaultName": "[concat('kv', substring(uniqueString(parameters('branch')), 0, 4), 'xxxx', substring(parameters('commit'), 0, min(length(parameters('commit')), 7)))]",
54+
"keyVaultSecret_ServicePrincipalClientSecret": "devopsServicePrincipalClientSecret",
55+
"keyVaultSecret_StorageSaSToken": "StorageSaSToken",
56+
"keyVaultSecret_StorageKey": "StorageKey",
57+
"keyVaultSecret_functionsKey": "functionsKey",
5458

5559
"applicationInsightsApiVersion": "2020-02-02-preview",
5660
"applicationInsightsName": "[concat('appinsights', substring(uniqueString(parameters('branch')), 0, 4), 'xxxx', substring(parameters('commit'), 0, min(length(parameters('commit')), 7)))]",
@@ -297,7 +301,7 @@
297301
{
298302
"type": "secrets",
299303
"apiVersion": "[variables('keyVaultApiVersion')]",
300-
"name": "StorageSaSToken",
304+
"name": "[variables('keyVaultSecret_StorageSaSToken')]",
301305
"dependsOn": [
302306
"[concat('Microsoft.KeyVault/vaults/', variables('keyVaultName'))]",
303307
"[concat('Microsoft.Storage/storageAccounts/', variables('adlsStorageAccountName'))]"
@@ -309,7 +313,7 @@
309313
{
310314
"type": "secrets",
311315
"apiVersion": "[variables('keyVaultApiVersion')]",
312-
"name": "devopsServicePrincipalClientSecret",
316+
"name": "[variables('keyVaultSecret_ServicePrincipalClientSecret')]",
313317
"dependsOn": [
314318
"[concat('Microsoft.KeyVault/vaults/', variables('keyVaultName'))]"
315319
],
@@ -320,15 +324,31 @@
320324
{
321325
"type": "secrets",
322326
"apiVersion": "[variables('keyVaultApiVersion')]",
323-
"name": "functionsKey",
327+
"name": "[variables('keyVaultSecret_functionsKey')]",
324328
"dependsOn": [
325329
"[concat('Microsoft.KeyVault/vaults/', variables('keyVaultName'))]",
326330
"[resourceId('Microsoft.Web/sites', variables('functionsAppName'))]"
327331
],
328332
"properties": {
329333
"value": "[listKeys(concat(resourceId('Microsoft.Web/sites', variables('functionsAppName')), '/host/default/'), variables('functionsAppApiVersion')).functionKeys.default]"
330334
}
335+
},
336+
{
337+
"type": "secrets",
338+
"apiVersion": "[variables('keyVaultApiVersion')]",
339+
"name": "[variables('keyVaultSecret_StorageKey')]",
340+
"dependsOn": [
341+
"[concat('Microsoft.KeyVault/vaults/', variables('keyVaultName'))]",
342+
"[resourceId('Microsoft.Web/sites', variables('functionsAppName'))]"
343+
],
344+
"properties": {
345+
"value": "[listKeys(variables('adlsStorageAccountResourceId'), variables('storageAccountApiVersion')).keys[0].value]"
346+
}
331347
}
348+
349+
350+
351+
332352
]
333353
},
334354

@@ -551,8 +571,38 @@
551571
"storageAccountContainerSasKey": {
552572
"type": "string",
553573
"value": "[listAccountSas(variables('adlsStorageAccountName'), variables('storageAccountApiVersion'), parameters('adlsStorageAccountSasProperties')).accountSasToken]"
554-
}
574+
},
555575

556-
576+
577+
578+
"runSettings": {
579+
"type": "string",
580+
"value": "[
581+
concat('<?xml version=\"1.0\" encoding=\"utf-8\"?>',
582+
'<RunSettings>',
583+
' <TestRunParameters>',
584+
' <Parameter name=\"UseFunctionsEmulator\" value=\"true\" />',
585+
' <Parameter name=\"FunctionsAppName\" value=\"', variables('functionsAppName'), '\" />',
586+
' <Parameter name=\"FunctionsAppUrl\" value=\"', reference(resourceId('Microsoft.Web/sites', variables('functionsAppName')), variables('functionsAppApiVersion'), 'full').properties.hostNames[0], '\" />',
587+
' <Parameter name=\"FunctionsAppKey\" value=\"', listKeys(concat(resourceId('Microsoft.Web/sites', variables('functionsAppName')), '/host/default/'), variables('functionsAppApiVersion')).functionKeys.default, '\" />',
588+
' <Parameter name=\"FunctionsAppKeyName\" value=\"', variables('keyVaultSecret_functionsKey'), '\" />',
589+
' <Parameter name=\"StorageAccountName\" value=\"', variables('adlsStorageAccountName'), '\" />',
590+
' <Parameter name=\"StorageContainerName\" value=\"', parameters('adlsStorageAccountContainerName'), '\" />',
591+
' <Parameter name=\"KeyVaultName\" value=\"', variables('keyVaultName'), '\" />',
592+
' <Parameter name=\"ServicePrincipalName\" value=\"', parameters('devopsServicePrincipalCredentials').client_id, '\" />',
593+
' <Parameter name=\"ServicePrincipalSecret\" value=\"', parameters('devopsServicePrincipalCredentials').client_secret, '\" />',
594+
' <Parameter name=\"ServicePrincipalNameKeyName\" value=\"', variables('keyVaultSecret_ServicePrincipalClientSecret'), '\" />',
595+
' <Parameter name=\"StorageContainerSasToken\" value=\"', replace(listAccountSas(variables('adlsStorageAccountName'), variables('storageAccountApiVersion'), parameters('adlsStorageAccountSasProperties')).accountSasToken, '&', '&amp;'), '\" />',
596+
' <Parameter name=\"StorageContainerSasTokenKeyName\" value=\"', variables('keyVaultSecret_StorageSaSToken'), '\" />',
597+
' <Parameter name=\"StorageAccountAccessKey\" value=\"', listKeys(variables('adlsStorageAccountResourceId'), variables('storageAccountApiVersion')).keys[0].value, '\" />',
598+
' <Parameter name=\"StorageAccountAccessKeyKeyName\" value=\"', variables('keyVaultSecret_StorageKey'), '\" />',
599+
' </TestRunParameters>',
600+
'</RunSettings>'
601+
)
602+
]"
603+
}
557604
}
558605
}
606+
607+
608+

0 commit comments

Comments
 (0)