diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 3a0066ff..37d5791a 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -71,7 +71,22 @@ jobs: continue-on-error: false with: creds: ${{ secrets.AZURE_CREDENTIALS }} - + + - name: Create Resource Group + uses: azure/powershell@v1 + continue-on-error: false + with: + inlineScript: | + az group create --name "${{ env.LOAD_TEST_RESOURCE_GROUP }}" --location "${{ env.LOCATION }}" + azPSVersion: "latest" + + - name: Create Azure Load Testing resource + uses: azure/arm-deploy@v1 + with: + resourceGroupName: ${{ env.LOAD_TEST_RESOURCE_GROUP }} + template: ./ARMTemplate/template.json + parameters: ./ARMTemplate/parameters.json name=${{ env.LOAD_TEST_RESOURCE }} location="${{ env.LOCATION }}" + - name: 'Azure Load Testing' uses: azure/load-testing@v1 with: diff --git a/ARMTemplate/parameters.json b/ARMTemplate/parameters.json new file mode 100644 index 00000000..536093e9 --- /dev/null +++ b/ARMTemplate/parameters.json @@ -0,0 +1,15 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "name": { + "value": "" + }, + "location": { + "value": "" + }, + "tags": { + "value": {} + } + } +} diff --git a/ARMTemplate/template.json b/ARMTemplate/template.json new file mode 100644 index 00000000..bc85fc30 --- /dev/null +++ b/ARMTemplate/template.json @@ -0,0 +1,24 @@ +{ + "$schema": "http://schema.management.azure.com/schemas/2019-08-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "name": { + "type": "String" + }, + "location": { + "type": "String" + }, + "tags": { + "type": "Object" + } + }, + "resources": [ + { + "type": "Microsoft.LoadTestService/loadtests", + "apiVersion": "2021-12-01-preview", + "name": "[parameters('name')]", + "location": "[parameters('location')]", + "tags": "[parameters('tags')]" + } + ] +} diff --git a/azure-pipelines.yml b/azure-pipelines.yml index f1348617..6d74d1f2 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -127,6 +127,21 @@ stages: pool: vmImage: ubuntu-latest steps: + + - task: AzureResourceManagerTemplateDeployment@3 + inputs: + deploymentScope: 'Resource Group' + azureResourceManagerConnection: $(serviceConnection) + subscriptionId: $(azureSubscriptionId) + action: 'Create Or Update Resource Group' + resourceGroupName: $(loadTestResourceGroup) + location: '$(location)' + templateLocation: 'Linked artifact' + csmFile: '$(System.DefaultWorkingDirectory)/ARMTemplate/template.json' + csmParametersFile: '$(System.DefaultWorkingDirectory)/ARMTemplate/parameters.json' + overrideParameters: '-name $(loadTestResource) -location "$(location)"' + deploymentMode: 'Incremental' + - task: AzureLoadTest@1 inputs: azureSubscription: $(serviceConnection)