From b3d69d709ea046eed088f4e2218a579eb9770025 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Fri, 30 Oct 2020 14:42:28 +0000 Subject: [PATCH 01/24] added resourcegroup deployment --- .github/workflows/infraworkflow.yml | 42 +++++++++++++++++++ ARM/azuredeploy.resourcegroup.json | 31 ++++++++++++++ ARM/azuredeploy.resourcegroup.parameters.json | 12 ++++++ 3 files changed, 85 insertions(+) create mode 100644 .github/workflows/infraworkflow.yml create mode 100644 ARM/azuredeploy.resourcegroup.json create mode 100644 ARM/azuredeploy.resourcegroup.parameters.json diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml new file mode 100644 index 0000000..646e4a1 --- /dev/null +++ b/.github/workflows/infraworkflow.yml @@ -0,0 +1,42 @@ +name: workflow to deploy an ARM Template to a Subscription Scope +on: + push: + paths: + - 'ARM/**' + +env: + AZURE_SUBSCRIPTION_ID: << Subscription Id >> # set this to your Azure Subscription Id + + jobs: + build-and-deploy-to-dev: + runs-on: ubuntu-latest + steps: + + # Authentication + # Set up the following secrets in your repository: AZURE_CREDENTIALS + # Below *az ad* command scopes the service principal to a specific Azure subscription *{subscription-id}* + # az ad sp create-for-rbac --name "myApp" --role contributor --scopes /subscriptions/{subscription-id} --sdk-auth + # Replace {subscription-id} with the your subscription, resource group details. + # Example: az ad sp create-for-rbac --name "myApp" --role contributor --scopes /subscriptions/e1046c08-7072-****-****-************ --sdk-auth + # Place the output of the above command as value of secret variable - AZURE_CREDENTIALS + # For details on usage of secrets, please refer https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets + - name: Azure Login + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + + # Checkout + - name: Checkout + uses: actions/checkout@v1 + + # Deployment of template + - name: Deploy ARM Template + uses: azure/arm-deploy@v1 + with: + # You can change these environment variables for your configuration: AZURE_SUBSCRIPTION_ID + scope: subscription + subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} + region: centralus # Set this to your target region + template: $GITHUB_WORKSPACE/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file + parameters: $GITHUB_WORKSPACE/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file + \ No newline at end of file diff --git a/ARM/azuredeploy.resourcegroup.json b/ARM/azuredeploy.resourcegroup.json new file mode 100644 index 0000000..2325339 --- /dev/null +++ b/ARM/azuredeploy.resourcegroup.json @@ -0,0 +1,31 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2018-05-01/subscriptionDeploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "rgName": { + "type": "string", + "metadata": { + "description": "Name of the resourceGroup to create" + } + }, + "rgLocation": { + "type": "string", + "metadata": { + "description": "Location for the resourceGroup" + } + } + }, + "variables": { }, + "resources": [ + { + "type": "Microsoft.Resources/resourceGroups", + "apiVersion": "2019-10-01", + "name": "[parameters('rgName')]", + "location": "[parameters('rgLocation')]", + "tags": { + "Note": "subscription level deployment" + }, + "properties": {} + } + ] + } \ No newline at end of file diff --git a/ARM/azuredeploy.resourcegroup.parameters.json b/ARM/azuredeploy.resourcegroup.parameters.json new file mode 100644 index 0000000..a9f3f32 --- /dev/null +++ b/ARM/azuredeploy.resourcegroup.parameters.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "rgName": { + "value": "GEN-UNIQUE" + }, + "rgLocation": { + "value": "southcentralus" + } + } + } \ No newline at end of file From 4a44bea48f4941d2b6fef20108356eb70b05cc82 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Fri, 30 Oct 2020 14:46:16 +0000 Subject: [PATCH 02/24] fixed error --- .github/workflows/infraworkflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index 646e4a1..54ee081 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -7,7 +7,7 @@ on: env: AZURE_SUBSCRIPTION_ID: << Subscription Id >> # set this to your Azure Subscription Id - jobs: +jobs: build-and-deploy-to-dev: runs-on: ubuntu-latest steps: From 4145fe5c0fe0cb3991feb60e201c8c1e1ee78023 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Fri, 30 Oct 2020 14:57:17 +0000 Subject: [PATCH 03/24] added workflow dispatch --- .github/workflows/infraworkflow.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index 54ee081..5bb0bd1 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -3,6 +3,7 @@ on: push: paths: - 'ARM/**' + workflow_dispatch env: AZURE_SUBSCRIPTION_ID: << Subscription Id >> # set this to your Azure Subscription Id From d66eed5bd7b682ac249df0f1948612017ba7f463 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Fri, 30 Oct 2020 14:59:15 +0000 Subject: [PATCH 04/24] default value --- .github/workflows/infraworkflow.yml | 1 - ARM/azuredeploy.resourcegroup.json | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index 5bb0bd1..54ee081 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -3,7 +3,6 @@ on: push: paths: - 'ARM/**' - workflow_dispatch env: AZURE_SUBSCRIPTION_ID: << Subscription Id >> # set this to your Azure Subscription Id diff --git a/ARM/azuredeploy.resourcegroup.json b/ARM/azuredeploy.resourcegroup.json index 2325339..ef4de1e 100644 --- a/ARM/azuredeploy.resourcegroup.json +++ b/ARM/azuredeploy.resourcegroup.json @@ -12,7 +12,8 @@ "type": "string", "metadata": { "description": "Location for the resourceGroup" - } + }, + "defaultValue": "southcentralus" } }, "variables": { }, From b6147e498f3f8ed9032b8f44363f6f4a52cd7f2f Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Fri, 30 Oct 2020 15:08:41 +0000 Subject: [PATCH 05/24] default value --- .github/workflows/infraworkflow.yml | 4 ++-- ARM/azuredeploy.resourcegroup.json | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index 54ee081..1296e28 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -5,7 +5,7 @@ on: - 'ARM/**' env: - AZURE_SUBSCRIPTION_ID: << Subscription Id >> # set this to your Azure Subscription Id + AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} # set this to your Azure Subscription Id jobs: build-and-deploy-to-dev: @@ -13,7 +13,7 @@ jobs: steps: # Authentication - # Set up the following secrets in your repository: AZURE_CREDENTIALS + # Set up the following secrets in your repository: AZURE_CREDENTIALS, AZURE_SUBSCRIPTION_ID # Below *az ad* command scopes the service principal to a specific Azure subscription *{subscription-id}* # az ad sp create-for-rbac --name "myApp" --role contributor --scopes /subscriptions/{subscription-id} --sdk-auth # Replace {subscription-id} with the your subscription, resource group details. diff --git a/ARM/azuredeploy.resourcegroup.json b/ARM/azuredeploy.resourcegroup.json index ef4de1e..2325339 100644 --- a/ARM/azuredeploy.resourcegroup.json +++ b/ARM/azuredeploy.resourcegroup.json @@ -12,8 +12,7 @@ "type": "string", "metadata": { "description": "Location for the resourceGroup" - }, - "defaultValue": "southcentralus" + } } }, "variables": { }, From 367286142914d3639ba7260510a56330b0604f5a Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Fri, 30 Oct 2020 15:11:18 +0000 Subject: [PATCH 06/24] default value --- .github/workflows/infraworkflow.yml | 4 ++-- ARM/azuredeploy.resourcegroup.json | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index 1296e28..d982c0f 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -37,6 +37,6 @@ jobs: scope: subscription subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} region: centralus # Set this to your target region - template: $GITHUB_WORKSPACE/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file - parameters: $GITHUB_WORKSPACE/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file + template: ${{ env.workspace }}/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file + parameters: ${{ env.workspace }}/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file \ No newline at end of file diff --git a/ARM/azuredeploy.resourcegroup.json b/ARM/azuredeploy.resourcegroup.json index 2325339..ef4de1e 100644 --- a/ARM/azuredeploy.resourcegroup.json +++ b/ARM/azuredeploy.resourcegroup.json @@ -12,7 +12,8 @@ "type": "string", "metadata": { "description": "Location for the resourceGroup" - } + }, + "defaultValue": "southcentralus" } }, "variables": { }, From 87d104ca74ca8be709b662bad2c01667b5f0e78c Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Fri, 30 Oct 2020 15:17:06 +0000 Subject: [PATCH 07/24] default value --- .github/workflows/infraworkflow.yml | 6 +++--- ARM/azuredeploy.resourcegroup.json | 3 +-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index d982c0f..9c973bc 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -27,7 +27,7 @@ jobs: # Checkout - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 # Deployment of template - name: Deploy ARM Template @@ -37,6 +37,6 @@ jobs: scope: subscription subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} region: centralus # Set this to your target region - template: ${{ env.workspace }}/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file - parameters: ${{ env.workspace }}/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file + template: $GITHUB_WORKSPACE/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file + parameters: $GITHUB_WORKSPACE/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file \ No newline at end of file diff --git a/ARM/azuredeploy.resourcegroup.json b/ARM/azuredeploy.resourcegroup.json index ef4de1e..2325339 100644 --- a/ARM/azuredeploy.resourcegroup.json +++ b/ARM/azuredeploy.resourcegroup.json @@ -12,8 +12,7 @@ "type": "string", "metadata": { "description": "Location for the resourceGroup" - }, - "defaultValue": "southcentralus" + } } }, "variables": { }, From c7af86ac6c6860ecd23c6ad3b73dbec46176ec0d Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 11:56:33 +0000 Subject: [PATCH 08/24] changed parg --- .github/workflows/infraworkflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index 9c973bc..3b10491 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -37,6 +37,6 @@ jobs: scope: subscription subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} region: centralus # Set this to your target region - template: $GITHUB_WORKSPACE/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file - parameters: $GITHUB_WORKSPACE/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file + template: vermegi/dotnet_core_sample/vermegi/infra/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file + parameters: vermegi/dotnet_core_sample/vermegi/infra/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file \ No newline at end of file From 08c70362f8449eefe76a774f0bfa2bb455d112c6 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 11:57:20 +0000 Subject: [PATCH 09/24] location change --- ARM/azuredeploy.resourcegroup.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ARM/azuredeploy.resourcegroup.json b/ARM/azuredeploy.resourcegroup.json index 2325339..ef4de1e 100644 --- a/ARM/azuredeploy.resourcegroup.json +++ b/ARM/azuredeploy.resourcegroup.json @@ -12,7 +12,8 @@ "type": "string", "metadata": { "description": "Location for the resourceGroup" - } + }, + "defaultValue": "southcentralus" } }, "variables": { }, From b93923e7a46496041cfdef7870e6337b7de722ab Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 12:04:20 +0000 Subject: [PATCH 10/24] repo path --- .github/workflows/infraworkflow.yml | 6 ++++-- ARM/azuredeploy.resourcegroup.json | 3 +-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index 3b10491..813b992 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -28,6 +28,8 @@ jobs: # Checkout - name: Checkout uses: actions/checkout@v2 + with: + path: repo # Deployment of template - name: Deploy ARM Template @@ -37,6 +39,6 @@ jobs: scope: subscription subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} region: centralus # Set this to your target region - template: vermegi/dotnet_core_sample/vermegi/infra/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file - parameters: vermegi/dotnet_core_sample/vermegi/infra/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file + template: repo/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file + parameters: repo/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file \ No newline at end of file diff --git a/ARM/azuredeploy.resourcegroup.json b/ARM/azuredeploy.resourcegroup.json index ef4de1e..2325339 100644 --- a/ARM/azuredeploy.resourcegroup.json +++ b/ARM/azuredeploy.resourcegroup.json @@ -12,8 +12,7 @@ "type": "string", "metadata": { "description": "Location for the resourceGroup" - }, - "defaultValue": "southcentralus" + } } }, "variables": { }, From cbf3bfb38dbc403356ad585929d8e6a0572ed92d Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 12:18:43 +0000 Subject: [PATCH 11/24] changed rg name added resource templates --- .github/workflows/infraworkflow.yml | 20 +++++++-- ARM/azuredeploy.json | 63 +++++++++++++++++++++++++++++ ARM/azuredeploy.parameters.json | 12 ++++++ 3 files changed, 92 insertions(+), 3 deletions(-) create mode 100644 ARM/azuredeploy.json create mode 100644 ARM/azuredeploy.parameters.json diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index 813b992..f576bc1 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -5,7 +5,8 @@ on: - 'ARM/**' env: - AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} # set this to your Azure Subscription Id + AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} # set this to your Azure Subscription Id + RESOURCEGROUP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name jobs: build-and-deploy-to-dev: @@ -32,7 +33,7 @@ jobs: path: repo # Deployment of template - - name: Deploy ARM Template + - name: Deploy ARM Template resourcegroup uses: azure/arm-deploy@v1 with: # You can change these environment variables for your configuration: AZURE_SUBSCRIPTION_ID @@ -41,4 +42,17 @@ jobs: region: centralus # Set this to your target region template: repo/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file parameters: repo/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file - \ No newline at end of file + parameters: rgName=${{env.RESOURCEGROUP_NAME}} #override rgName in parameters file + + # Deployment of template + - name: Deploy ARM Template resources + uses: azure/arm-deploy@v1 + with: + # You can change these environment variables for your configuration: AZURE_SUBSCRIPTION_ID + scope: resourcegroup + subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} + resourcegroup: ${{env.RESOURCEGROUP_NAME}} + region: centralus # Set this to your target region + template: repo/ARM/azuredeploy.json # Set this to the location of your template file + parameters: repo/ARM/azuredeploy.parameters.json # Set this to the location of your parameters file + \ No newline at end of file diff --git a/ARM/azuredeploy.json b/ARM/azuredeploy.json new file mode 100644 index 0000000..2d89ed7 --- /dev/null +++ b/ARM/azuredeploy.json @@ -0,0 +1,63 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "webappName": { + "type": "string", + "metadata": { + "description": "Name of your web app" + } + }, + "aspName": { + "type": "string", + "metadata": { + "description": "Name of your app service plan" + } + }, + "aspSKU": { + "type": "string", + "metadata": { + "description": "description" + }, + "defaultValue": "S1" + } + }, + "functions": [], + "variables": {}, + "resources": [ + { + "name": "[parameters('webappName')]", + "type": "Microsoft.Web/sites", + "apiVersion": "2018-11-01", + "location": "[resourceGroup().location]", + "tags": { + "[concat('hidden-related:', resourceGroup().id, '/providers/Microsoft.Web/serverfarms/', parameters('aspName'))]": "Resource", + "displayName": "[parameters('webappName')]" + }, + "dependsOn": [ + "[resourceId('Microsoft.Web/serverfarms', '', parameters('aspName'))]" + ], + "properties": { + "name": "[parameters('webappName')]", + "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', '', parameters('aspName'))]" + } + }, + { + "name": "[parameters('aspName')]", + "type": "Microsoft.Web/serverfarms", + "apiVersion": "2018-02-01", + "location": "[resourceGroup().location]", + "sku": { + "name": "[parameters('aspSKU')]", + "capacity": 1 + }, + "tags": { + "displayName": "[parameters('aspName')]" + }, + "properties": { + "name": "[parameters('aspName')]" + } + } + ], + "outputs": {} +} \ No newline at end of file diff --git a/ARM/azuredeploy.parameters.json b/ARM/azuredeploy.parameters.json new file mode 100644 index 0000000..f84a146 --- /dev/null +++ b/ARM/azuredeploy.parameters.json @@ -0,0 +1,12 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "webappName":{ + "value": "GEN-UNIQUE" + } , + "aspName": { + "value": "GEN-UNIQUE" + } + } +} \ No newline at end of file From a6cd10dd2f09917af69963683787b8bea78453f7 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 12:27:16 +0000 Subject: [PATCH 12/24] no extra params --- .github/workflows/infraworkflow.yml | 4 ++-- ARM/azuredeploy.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index f576bc1..3a3650f 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -41,8 +41,8 @@ jobs: subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} region: centralus # Set this to your target region template: repo/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file - parameters: repo/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file - parameters: rgName=${{env.RESOURCEGROUP_NAME}} #override rgName in parameters file + #parameters: repo/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file + parameters: rgName=${{env.RESOURCEGROUP_NAME}} rgLocation=centralus #override rgName in parameters file # Deployment of template - name: Deploy ARM Template resources diff --git a/ARM/azuredeploy.json b/ARM/azuredeploy.json index 2d89ed7..fb0dc85 100644 --- a/ARM/azuredeploy.json +++ b/ARM/azuredeploy.json @@ -19,7 +19,7 @@ "metadata": { "description": "description" }, - "defaultValue": "S1" + "defaultValue": "S2" } }, "functions": [], From 8ddad68d6e92b129eadb327a0fb8ebdb20291968 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 12:30:05 +0000 Subject: [PATCH 13/24] resourcegroupname --- .github/workflows/infraworkflow.yml | 2 +- ARM/azuredeploy.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index 3a3650f..c49c2bc 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -51,7 +51,7 @@ jobs: # You can change these environment variables for your configuration: AZURE_SUBSCRIPTION_ID scope: resourcegroup subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} - resourcegroup: ${{env.RESOURCEGROUP_NAME}} + resourceGroupName: ${{env.RESOURCEGROUP_NAME}} region: centralus # Set this to your target region template: repo/ARM/azuredeploy.json # Set this to the location of your template file parameters: repo/ARM/azuredeploy.parameters.json # Set this to the location of your parameters file diff --git a/ARM/azuredeploy.json b/ARM/azuredeploy.json index fb0dc85..2d89ed7 100644 --- a/ARM/azuredeploy.json +++ b/ARM/azuredeploy.json @@ -19,7 +19,7 @@ "metadata": { "description": "description" }, - "defaultValue": "S2" + "defaultValue": "S1" } }, "functions": [], From d4a42c7e370aff476aad9e851acaa5bbf4573dc4 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 12:35:53 +0000 Subject: [PATCH 14/24] change params --- .github/workflows/infraworkflow.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index c49c2bc..cba87de 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -3,10 +3,13 @@ on: push: paths: - 'ARM/**' + - '.github/workflows/infraworkflow.yml' env: AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} # set this to your Azure Subscription Id RESOURCEGROUP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name + WEBAPP_NAME: demo-webapp-gh-actions-wa # set this to your preferred resource group name + ASP_NAME: demo-webapp-gh-actions-asp # set this to your preferred resource group name jobs: build-and-deploy-to-dev: @@ -41,7 +44,6 @@ jobs: subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} region: centralus # Set this to your target region template: repo/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file - #parameters: repo/ARM/azuredeploy.resourcegroup.parameters.json # Set this to the location of your parameters file parameters: rgName=${{env.RESOURCEGROUP_NAME}} rgLocation=centralus #override rgName in parameters file # Deployment of template @@ -54,5 +56,5 @@ jobs: resourceGroupName: ${{env.RESOURCEGROUP_NAME}} region: centralus # Set this to your target region template: repo/ARM/azuredeploy.json # Set this to the location of your template file - parameters: repo/ARM/azuredeploy.parameters.json # Set this to the location of your parameters file + parameters: webappName=${{env.WEBAPP_NAME}} aspName=${{env.ASP_NAME}} # Set this to the location of your parameters file \ No newline at end of file From 8ad4b162ed011395cf68c3fb911079bd6b550f00 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 12:39:10 +0000 Subject: [PATCH 15/24] shorted wa name --- .github/workflows/infraworkflow.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index cba87de..4f49005 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -8,8 +8,8 @@ on: env: AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} # set this to your Azure Subscription Id RESOURCEGROUP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name - WEBAPP_NAME: demo-webapp-gh-actions-wa # set this to your preferred resource group name - ASP_NAME: demo-webapp-gh-actions-asp # set this to your preferred resource group name + WEBAPP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name + ASP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name jobs: build-and-deploy-to-dev: From 435fa10bff640f00d3f9183e60cc2a33b8559178 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 12:44:18 +0000 Subject: [PATCH 16/24] fixed template error --- ARM/azuredeploy.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ARM/azuredeploy.json b/ARM/azuredeploy.json index 2d89ed7..f4f84a7 100644 --- a/ARM/azuredeploy.json +++ b/ARM/azuredeploy.json @@ -35,11 +35,11 @@ "displayName": "[parameters('webappName')]" }, "dependsOn": [ - "[resourceId('Microsoft.Web/serverfarms', '', parameters('aspName'))]" + "[resourceId('Microsoft.Web/serverfarms', parameters('aspName'))]" ], "properties": { "name": "[parameters('webappName')]", - "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', '', parameters('aspName'))]" + "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('aspName'))]" } }, { From 25595bb083104e60cf053712ca83845cb5daffd1 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 12:53:24 +0000 Subject: [PATCH 17/24] added slot --- ARM/azuredeploy.json | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/ARM/azuredeploy.json b/ARM/azuredeploy.json index f4f84a7..3e8f90d 100644 --- a/ARM/azuredeploy.json +++ b/ARM/azuredeploy.json @@ -57,6 +57,23 @@ "properties": { "name": "[parameters('aspName')]" } + }, + { + "apiVersion": "2020-06-01", + "type": "Microsoft.Web/sites/slots", + "name": "[concat(parameters('webappName'), '/', 'staging')]", + "kind": "app", + "location": "[resourceGroup().location]", + "comments": "This specifies the web app slots.", + "tags": { + "displayName": "WebAppSlots" + }, + "properties": { + "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('aspName'))]" + }, + "dependsOn": [ + "[resourceId('Microsoft.Web/Sites', parameters('webappName'))]" + ] } ], "outputs": {} From 9395596d68e6b54817a34a7df85e5b954068e859 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 14:32:54 +0000 Subject: [PATCH 18/24] added slot deply --- .github/workflows/infraworkflow.yml | 7 ++++--- .github/workflows/workflow.yml | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index 4f49005..8d38f77 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -8,7 +8,7 @@ on: env: AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} # set this to your Azure Subscription Id RESOURCEGROUP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name - WEBAPP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name + AZURE_WEBAPP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name ASP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name jobs: @@ -56,5 +56,6 @@ jobs: resourceGroupName: ${{env.RESOURCEGROUP_NAME}} region: centralus # Set this to your target region template: repo/ARM/azuredeploy.json # Set this to the location of your template file - parameters: webappName=${{env.WEBAPP_NAME}} aspName=${{env.ASP_NAME}} # Set this to the location of your parameters file - \ No newline at end of file + parameters: webappName=${{env.AZURE_WEBAPP_NAME}} aspName=${{env.ASP_NAME}} # Set this to the location of your parameters file + +#TODO: download web app publish profile and add it as a secret to the repo \ No newline at end of file diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 4114d99..3dd50ad 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -4,6 +4,7 @@ on: push: branches: - master + - vermegi/infra pull_request: branches: - '*' @@ -39,12 +40,13 @@ jobs: dotnet build --configuration Release dotnet publish -c Release -o myapp - # Deploy to Azure Web apps + # Deploy to Azure Web apps staging slot - name: 'Run Azure webapp deploy action using publish profile credentials' uses: azure/webapps-deploy@v2 with: app-name: ${{ env.AZURE_WEBAPP_NAME }} # Replace with your app name publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }} # Define secret variable in repository settings as per action documentation package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp' + slot-name: staging # For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples From 747866f4478cbb58356fbbd1831e0e200597c2eb Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 14:40:48 +0000 Subject: [PATCH 19/24] added swap --- .github/workflows/infraworkflow.yml | 6 +++--- .github/workflows/workflow.yml | 7 +++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index 8d38f77..669decd 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -7,7 +7,7 @@ on: env: AZURE_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} # set this to your Azure Subscription Id - RESOURCEGROUP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name + AZURE_RESOURCEGROUP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name AZURE_WEBAPP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name ASP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name @@ -44,7 +44,7 @@ jobs: subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} region: centralus # Set this to your target region template: repo/ARM/azuredeploy.resourcegroup.json # Set this to the location of your template file - parameters: rgName=${{env.RESOURCEGROUP_NAME}} rgLocation=centralus #override rgName in parameters file + parameters: rgName=${{env.AZURE_RESOURCEGROUP_NAME}} rgLocation=centralus #override rgName in parameters file # Deployment of template - name: Deploy ARM Template resources @@ -53,7 +53,7 @@ jobs: # You can change these environment variables for your configuration: AZURE_SUBSCRIPTION_ID scope: resourcegroup subscriptionId: ${{ env.AZURE_SUBSCRIPTION_ID }} - resourceGroupName: ${{env.RESOURCEGROUP_NAME}} + resourceGroupName: ${{env.AZURE_RESOURCEGROUP_NAME}} region: centralus # Set this to your target region template: repo/ARM/azuredeploy.json # Set this to the location of your template file parameters: webappName=${{env.AZURE_WEBAPP_NAME}} aspName=${{env.ASP_NAME}} # Set this to the location of your parameters file diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 3dd50ad..d691503 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -19,6 +19,7 @@ env: AZURE_WEBAPP_NAME: dotnetcoreLinux # set this to your application's name AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root DOTNET_VERSION: '2.2.402' # set this to the dot net version to use + AZURE_RESOURCEGROUP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name jobs: build-and-deploy: @@ -49,4 +50,10 @@ jobs: package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp' slot-name: staging + - name: Swap to production slot + run: | + az webapp deployment slot swap --resource-group ${{ env.AZURE_RESOURCEGROUP_NAME }} --name ${{ env.AZURE_WEBAPP_NAME }} --slot staging --target-slot production + echo "Swap finished. App Service Application URL: https://$(az webapp show --resource-group ${{ env.AZURE_RESOURCEGROUP_NAME }} --name ${{ env.AZURE_WEBAPP_NAME }} --query hostNames[0] -o tsv)" + + # For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples From 1541a42a1365a36246fd8a9835e0acd518f78f36 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 14:43:13 +0000 Subject: [PATCH 20/24] added swap --- .github/workflows/workflow.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index d691503..537347a 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -55,5 +55,4 @@ jobs: az webapp deployment slot swap --resource-group ${{ env.AZURE_RESOURCEGROUP_NAME }} --name ${{ env.AZURE_WEBAPP_NAME }} --slot staging --target-slot production echo "Swap finished. App Service Application URL: https://$(az webapp show --resource-group ${{ env.AZURE_RESOURCEGROUP_NAME }} --name ${{ env.AZURE_WEBAPP_NAME }} --query hostNames[0] -o tsv)" - # For more samples to get started with GitHub Action workflows to deploy to Azure, refer to https://github.com/Azure/actions-workflow-samples From 3b2303ecc90ef0245b8e5c7267e9985dd3bc2d27 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 14:45:13 +0000 Subject: [PATCH 21/24] app name incorrect --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 537347a..0e78488 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -16,7 +16,7 @@ on: # # 2. Change these variables for your configuration: env: - AZURE_WEBAPP_NAME: dotnetcoreLinux # set this to your application's name + AZURE_WEBAPP_NAME: demo-webapp-gh-actions # set this to your application's name AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root DOTNET_VERSION: '2.2.402' # set this to the dot net version to use AZURE_RESOURCEGROUP_NAME: demo-webapp-gh-actions # set this to your preferred resource group name From cfbc103556a2f59ef0e97d2a66d8f2f84251c74b Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 2 Nov 2020 14:49:03 +0000 Subject: [PATCH 22/24] added az login --- .github/workflows/workflow.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 0e78488..2029f71 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -50,6 +50,11 @@ jobs: package: '${{ env.AZURE_WEBAPP_PACKAGE_PATH }}/myapp' slot-name: staging + - name: Login for az cli commands + uses: azure/login@v1 + with: + creds: ${{ secrets.AZURE_CREDENTIALS }} + - name: Swap to production slot run: | az webapp deployment slot swap --resource-group ${{ env.AZURE_RESOURCEGROUP_NAME }} --name ${{ env.AZURE_WEBAPP_NAME }} --slot staging --target-slot production From a7edec7a4f8913477f7691e6d548e7b63873e0dd Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Mon, 9 Nov 2020 08:37:52 +0000 Subject: [PATCH 23/24] replaced auth comment --- .github/workflows/infraworkflow.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/infraworkflow.yml b/.github/workflows/infraworkflow.yml index 669decd..cd58628 100644 --- a/.github/workflows/infraworkflow.yml +++ b/.github/workflows/infraworkflow.yml @@ -16,14 +16,7 @@ jobs: runs-on: ubuntu-latest steps: - # Authentication - # Set up the following secrets in your repository: AZURE_CREDENTIALS, AZURE_SUBSCRIPTION_ID - # Below *az ad* command scopes the service principal to a specific Azure subscription *{subscription-id}* - # az ad sp create-for-rbac --name "myApp" --role contributor --scopes /subscriptions/{subscription-id} --sdk-auth - # Replace {subscription-id} with the your subscription, resource group details. - # Example: az ad sp create-for-rbac --name "myApp" --role contributor --scopes /subscriptions/e1046c08-7072-****-****-************ --sdk-auth - # Place the output of the above command as value of secret variable - AZURE_CREDENTIALS - # For details on usage of secrets, please refer https://help.github.com/en/actions/configuring-and-managing-workflows/creating-and-storing-encrypted-secrets + # Please refer to https://github.com/Azure/login#configure-deployment-credentials for help on the Azure login action and setting up your secrets - name: Azure Login uses: azure/login@v1 with: From 26b2bf56959ef2bed7d9b77f2367f30c25a8fa13 Mon Sep 17 00:00:00 2001 From: Gitte Vermeiren Date: Fri, 22 Jan 2021 13:43:12 +0100 Subject: [PATCH 24/24] removed pull request trigger --- .github/workflows/workflow.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 2029f71..059b958 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -5,9 +5,6 @@ on: branches: - master - vermegi/infra - pull_request: - branches: - - '*' # CONFIGURATION # For help, go to https://github.com/Azure/Actions #