From e114e18c2b8edc55328cd8350701fefed1c5115f Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 12:34:17 +0530 Subject: [PATCH 01/23] Add template --- .gitignore | 1 + azure-pipelines.yml | 25 ++++++- config/azurefunctiondeploy.json | 128 ++++++++++++++++++++++++++++++++ config/config.ps1 | 35 +++++++++ 4 files changed, 188 insertions(+), 1 deletion(-) create mode 100644 config/azurefunctiondeploy.json create mode 100644 config/config.ps1 diff --git a/.gitignore b/.gitignore index c85813a..0e3a90f 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ /source/.vs/AzureFunctionWebAPI/v16 /source/tests/SampleAzureFunctionCode.Tests/obj +/source/.vs/AzureFunctionWebAPI/DesignTimeBuild/.dtbcache diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 74f8782..b8fb9a0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,7 +12,7 @@ variables: devazureSubscription: 'f27beff6-c5b7-41a5-bd50-2b9fce4760ca' # Function app name - devFunctionAppName: 'fcd-dev-web-app' + devFunctionAppName: 'fcd-dev-web-app-abc' # Agent VM image name vmImageName: 'vs2017-win2016' @@ -85,6 +85,29 @@ stages: testRunner: VSTest testResultsFiles: '**/*.trx' +- stage: Resource_Deployment + displayName: Run Test Cases + dependsOn: Start_Run_Test + condition: succeeded() + + jobs: + - job: Start_Resource_Deployment + displayName: Resources + pool: + vmImage: $(vmImageName) + + steps: + - task: AzurePowerShell@3 + displayName: 'Resource Deployment' + inputs: + azureSubscription: 'AzureFunction' + ScriptPath: $(System.DefaultWorkingDirectory)/config/config.ps1' + + - script: dotnet test $(System.DefaultWorkingDirectory)/source/tests/SampleAzureFunctionCode.Tests/SampleAzureFunctionCode.Tests.csproj --logger trx --collect "Code coverage" + - task: PublishTestResults@2 + inputs: + testRunner: VSTest + testResultsFiles: '**/*.trx' - stage: Dev_Deployment displayName: Dev Deployment stage diff --git a/config/azurefunctiondeploy.json b/config/azurefunctiondeploy.json new file mode 100644 index 0000000..fd8192f --- /dev/null +++ b/config/azurefunctiondeploy.json @@ -0,0 +1,128 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "appName": { + "type": "string", + "metadata": { + "description": "The name of the function app that you wish to create." + } + }, + "storageAccountType": { + "type": "string", + "defaultValue": "Standard_LRS", + "allowedValues": ["Standard_LRS", "Standard_GRS", "Standard_RAGRS"], + "metadata": { + "description": "Storage Account type" + } + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]", + "metadata": { + "description": "Location for all resources." + } + }, + "runtime": { + "type": "string", + "defaultValue": "node", + "allowedValues": ["node", "dotnet", "java"], + "metadata": { + "description": "The language worker runtime to load in the function app." + } + } + }, + "variables": { + "functionAppName": "[parameters('appName')]", + "hostingPlanName": "[parameters('appName')]", + "applicationInsightsName": "[parameters('appName')]", + "storageAccountName": "[concat(uniquestring(resourceGroup().id), 'azfunctions')]", + "storageAccountid": "[concat(resourceGroup().id,'/providers/','Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]", + "functionWorkerRuntime": "[parameters('runtime')]" + }, + "resources": [ + { + "type": "Microsoft.Storage/storageAccounts", + "name": "[variables('storageAccountName')]", + "apiVersion": "2016-12-01", + "location": "[parameters('location')]", + "kind": "Storage", + "sku": { + "name": "[parameters('storageAccountType')]" + } + }, + { + "type": "Microsoft.Web/serverfarms", + "apiVersion": "2018-02-01", + "name": "[variables('hostingPlanName')]", + "location": "[parameters('location')]", + "sku": { + "name": "Y1", + "tier": "Dynamic" + }, + "properties": { + "name": "[variables('hostingPlanName')]", + "computeMode": "Dynamic" + } + }, + { + "apiVersion": "2015-08-01", + "type": "Microsoft.Web/sites", + "name": "[variables('functionAppName')]", + "location": "[parameters('location')]", + "kind": "functionapp", + "dependsOn": [ + "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]", + "[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]" + ], + "properties": { + "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]", + "siteConfig": { + "appSettings": [ + { + "name": "AzureWebJobsStorage", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]" + }, + { + "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING", + "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(variables('storageAccountid'),'2015-05-01-preview').key1)]" + }, + { + "name": "WEBSITE_CONTENTSHARE", + "value": "[toLower(variables('functionAppName'))]" + }, + { + "name": "FUNCTIONS_EXTENSION_VERSION", + "value": "~2" + }, + { + "name": "WEBSITE_NODE_DEFAULT_VERSION", + "value": "~10" + }, + { + "name": "APPINSIGHTS_INSTRUMENTATIONKEY", + "value": "[reference(resourceId('microsoft.insights/components/', variables('applicationInsightsName')), '2015-05-01').InstrumentationKey]" + }, + { + "name": "FUNCTIONS_WORKER_RUNTIME", + "value": "[variables('functionWorkerRuntime')]" + } + ] + } + } + }, + { + "apiVersion": "2018-05-01-preview", + "name": "[variables('applicationInsightsName')]", + "type": "microsoft.insights/components", + "location": "East US", + "tags": { + "[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('applicationInsightsName'))]": "Resource" + }, + "properties": { + "ApplicationId": "[variables('applicationInsightsName')]", + "Request_Source": "IbizaWebAppExtensionCreate" + } + } + ] +} diff --git a/config/config.ps1 b/config/config.ps1 new file mode 100644 index 0000000..1d0d0cb --- /dev/null +++ b/config/config.ps1 @@ -0,0 +1,35 @@ +# Register Resource Providers if they're not already registered +$userId = "sahil.abhishek777@hotmail.com" +$passwd = ConvertTo-SecureString Abhinutan2018 -AsPlainText -Force +$cred = New-Object -TypeName System.Management.Automation.PSCredential($userId ,$passwd) +$resourceGroupName = "fcd-dev-webapp-abc" +$functionAppName = "fcd-dev-web-app-abc" + +# Create the parameters for the file, which for this template is the function app name. +$TemplateParams = @{"appName" = $functionAppName} + +Login-AzAccount -Credential $cred -TenantId "09abbc86-84ed-4481-83a3-4dc0f095d0b9" +Register-AzResourceProvider -ProviderNamespace "microsoft.web" +Register-AzResourceProvider -ProviderNamespace "microsoft.storage" + +$checkResourceGroupName = Get-AzResource -ResourceGroupName $resourceGroupName +if($checkResourceGroupName -eq $null){ + # Create a resource group for the function app + New-AzResourceGroup -Name "fcd-dev-webapp-new" -Location 'West Europe' +} +else{ + Write-Host "$resourceGroupName already exist" +} + +$checkFunctionAppName = Get-AzResource -ResourceGroupName $resourceGroupName -ResourceName $functionAppName +if($checkFunctionAppName -eq $null){ + # Deploy the template +New-AzResourceGroupDeployment -ResourceGroupName "fcd-dev-webapp-new" -TemplateFile azurefunctiondeploy.json -TemplateParameterObject $TemplateParams -Verbose +} +else{ + Write-Host "$functionAppName already exist" +} + + + + From 398b668434105bdce41ce6299ceeb09c25ad8594 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 12:43:55 +0530 Subject: [PATCH 02/23] Update the YAML files --- azure-pipelines.yml | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index b8fb9a0..0b84843 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -86,7 +86,7 @@ stages: testResultsFiles: '**/*.trx' - stage: Resource_Deployment - displayName: Run Test Cases + displayName: Resource Deployment dependsOn: Start_Run_Test condition: succeeded() @@ -102,16 +102,13 @@ stages: inputs: azureSubscription: 'AzureFunction' ScriptPath: $(System.DefaultWorkingDirectory)/config/config.ps1' + azurePowerShellVersion: LatestVersion - - script: dotnet test $(System.DefaultWorkingDirectory)/source/tests/SampleAzureFunctionCode.Tests/SampleAzureFunctionCode.Tests.csproj --logger trx --collect "Code coverage" - - task: PublishTestResults@2 - inputs: - testRunner: VSTest - testResultsFiles: '**/*.trx' + - stage: Dev_Deployment displayName: Dev Deployment stage - dependsOn: Start_Run_Test + dependsOn: Resource_Deployment condition: succeeded() jobs: @@ -129,7 +126,7 @@ stages: - task: AzureFunctionApp@1 displayName: 'Azure functions app deploy' inputs: - azureSubscription: '$(devazureSubscription)' + azureSubscription: 'AzureFunction' appType: functionApp appName: $(devFunctionAppName) package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip' From 8fb64888361e2ba1830cee4685a0198019a9e23b Mon Sep 17 00:00:00 2001 From: First Crazy Developer Date: Thu, 13 Feb 2020 12:51:28 +0530 Subject: [PATCH 03/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0b84843..3997399 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -101,7 +101,7 @@ stages: displayName: 'Resource Deployment' inputs: azureSubscription: 'AzureFunction' - ScriptPath: $(System.DefaultWorkingDirectory)/config/config.ps1' + ScriptPath: $(System.DefaultWorkingDirectory)/config/config.ps1 azurePowerShellVersion: LatestVersion From e1815c32a1727878e81c24a218c0ccc0c00a9176 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 13:06:46 +0530 Subject: [PATCH 04/23] Update login concepts --- config/config.ps1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/config/config.ps1 b/config/config.ps1 index 1d0d0cb..77ee34a 100644 --- a/config/config.ps1 +++ b/config/config.ps1 @@ -1,14 +1,12 @@ # Register Resource Providers if they're not already registered -$userId = "sahil.abhishek777@hotmail.com" -$passwd = ConvertTo-SecureString Abhinutan2018 -AsPlainText -Force -$cred = New-Object -TypeName System.Management.Automation.PSCredential($userId ,$passwd) + $resourceGroupName = "fcd-dev-webapp-abc" $functionAppName = "fcd-dev-web-app-abc" # Create the parameters for the file, which for this template is the function app name. $TemplateParams = @{"appName" = $functionAppName} -Login-AzAccount -Credential $cred -TenantId "09abbc86-84ed-4481-83a3-4dc0f095d0b9" + Register-AzResourceProvider -ProviderNamespace "microsoft.web" Register-AzResourceProvider -ProviderNamespace "microsoft.storage" From 465375e1d94f05122acdd3d5133c99de5409a05b Mon Sep 17 00:00:00 2001 From: First Crazy Developer Date: Thu, 13 Feb 2020 13:58:24 +0530 Subject: [PATCH 05/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 3997399..4180dcc 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -97,12 +97,12 @@ stages: vmImage: $(vmImageName) steps: - - task: AzurePowerShell@3 + - task: AzureCLI@2 displayName: 'Resource Deployment' inputs: azureSubscription: 'AzureFunction' - ScriptPath: $(System.DefaultWorkingDirectory)/config/config.ps1 - azurePowerShellVersion: LatestVersion + scriptType: ps + scriptPath: '$(System.DefaultWorkingDirectory)/config/config.ps1' From 1764815ded35ec59a734de9258c624b5dfc286cf Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 14:07:35 +0530 Subject: [PATCH 06/23] update --- config/config.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.ps1 b/config/config.ps1 index 77ee34a..21a4c0f 100644 --- a/config/config.ps1 +++ b/config/config.ps1 @@ -7,8 +7,8 @@ $functionAppName = "fcd-dev-web-app-abc" $TemplateParams = @{"appName" = $functionAppName} -Register-AzResourceProvider -ProviderNamespace "microsoft.web" -Register-AzResourceProvider -ProviderNamespace "microsoft.storage" +az provider register --namespace "microsoft.web" +az provider register --namespace "microsoft.storage" $checkResourceGroupName = Get-AzResource -ResourceGroupName $resourceGroupName if($checkResourceGroupName -eq $null){ From a279b6ea3276690e3ff39ce60af08348264c2299 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 14:31:18 +0530 Subject: [PATCH 07/23] update --- config/config.ps1 | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/config/config.ps1 b/config/config.ps1 index 21a4c0f..fce1f85 100644 --- a/config/config.ps1 +++ b/config/config.ps1 @@ -1,7 +1,7 @@ # Register Resource Providers if they're not already registered -$resourceGroupName = "fcd-dev-webapp-abc" -$functionAppName = "fcd-dev-web-app-abc" +$resourceGroupName = "fcd-dev-webapp-abc-old" +$functionAppName = "fcd-dev-web-app-abc-old" # Create the parameters for the file, which for this template is the function app name. $TemplateParams = @{"appName" = $functionAppName} @@ -10,19 +10,19 @@ $TemplateParams = @{"appName" = $functionAppName} az provider register --namespace "microsoft.web" az provider register --namespace "microsoft.storage" -$checkResourceGroupName = Get-AzResource -ResourceGroupName $resourceGroupName +$checkResourceGroupName = az resource show -g $resourceGroupName if($checkResourceGroupName -eq $null){ # Create a resource group for the function app - New-AzResourceGroup -Name "fcd-dev-webapp-new" -Location 'West Europe' + az group create -n "fcd-dev-webapp-new" -l 'West Europe' } else{ Write-Host "$resourceGroupName already exist" } -$checkFunctionAppName = Get-AzResource -ResourceGroupName $resourceGroupName -ResourceName $functionAppName +$checkFunctionAppName = az resource show -g $resourceGroupName -n $functionAppName if($checkFunctionAppName -eq $null){ # Deploy the template -New-AzResourceGroupDeployment -ResourceGroupName "fcd-dev-webapp-new" -TemplateFile azurefunctiondeploy.json -TemplateParameterObject $TemplateParams -Verbose +az group deployment create -g @resourceGroupName --template-file azurefunctiondeploy.json --parameters $TemplateParams } else{ Write-Host "$functionAppName already exist" From df70f4dd9443a0541e617d433bd12b3531caaf75 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 14:57:46 +0530 Subject: [PATCH 08/23] update az exist for group --- config/config.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.ps1 b/config/config.ps1 index fce1f85..9089f91 100644 --- a/config/config.ps1 +++ b/config/config.ps1 @@ -10,8 +10,8 @@ $TemplateParams = @{"appName" = $functionAppName} az provider register --namespace "microsoft.web" az provider register --namespace "microsoft.storage" -$checkResourceGroupName = az resource show -g $resourceGroupName -if($checkResourceGroupName -eq $null){ + +if($(az group exists --name $resourceGroupName) == false){ # Create a resource group for the function app az group create -n "fcd-dev-webapp-new" -l 'West Europe' } From 526d18cde785c91ccacd0c9d1840fd37eabe03ec Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 15:58:10 +0530 Subject: [PATCH 09/23] update config file --- config/config.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/config.ps1 b/config/config.ps1 index 9089f91..f73b298 100644 --- a/config/config.ps1 +++ b/config/config.ps1 @@ -11,7 +11,7 @@ az provider register --namespace "microsoft.web" az provider register --namespace "microsoft.storage" -if($(az group exists --name $resourceGroupName) == false){ +if(! az group exists $resourceGroupName){ # Create a resource group for the function app az group create -n "fcd-dev-webapp-new" -l 'West Europe' } @@ -19,7 +19,7 @@ else{ Write-Host "$resourceGroupName already exist" } -$checkFunctionAppName = az resource show -g $resourceGroupName -n $functionAppName +$checkFunctionAppName = az functionapp show -g $resourceGroupName -n $functionAppName if($checkFunctionAppName -eq $null){ # Deploy the template az group deployment create -g @resourceGroupName --template-file azurefunctiondeploy.json --parameters $TemplateParams From 6160b99680d4207bd171b244d17a17b00b32b3b2 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 16:05:30 +0530 Subject: [PATCH 10/23] sample --- config/config.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/config.ps1 b/config/config.ps1 index f73b298..74ac720 100644 --- a/config/config.ps1 +++ b/config/config.ps1 @@ -11,7 +11,7 @@ az provider register --namespace "microsoft.web" az provider register --namespace "microsoft.storage" -if(! az group exists $resourceGroupName){ +if(!az group exists -n $resourceGroupName){ # Create a resource group for the function app az group create -n "fcd-dev-webapp-new" -l 'West Europe' } From c9f51c3d9ab11ee193f76873f561c20748ca946e Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 18:52:27 +0530 Subject: [PATCH 11/23] Update the config file --- config/config.ps1 | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/config/config.ps1 b/config/config.ps1 index 74ac720..45daf72 100644 --- a/config/config.ps1 +++ b/config/config.ps1 @@ -1,7 +1,7 @@ # Register Resource Providers if they're not already registered -$resourceGroupName = "fcd-dev-webapp-abc-old" -$functionAppName = "fcd-dev-web-app-abc-old" +$resourceGroupName = "fcd-dev-function" +$functionAppName = "fcd-dev-web-app" # Create the parameters for the file, which for this template is the function app name. $TemplateParams = @{"appName" = $functionAppName} @@ -10,24 +10,24 @@ $TemplateParams = @{"appName" = $functionAppName} az provider register --namespace "microsoft.web" az provider register --namespace "microsoft.storage" +$resourceExist = az group exists -n $resourceGroupName -if(!az group exists -n $resourceGroupName){ +if($resourceExist -eq $true){ # Create a resource group for the function app - az group create -n "fcd-dev-webapp-new" -l 'West Europe' + Write-Host "resources exist" } -else{ - Write-Host "$resourceGroupName already exist" +else{ + Write-Host "resources not exist" + az group create -n $resourceGroupName -l 'West Europe' } $checkFunctionAppName = az functionapp show -g $resourceGroupName -n $functionAppName if($checkFunctionAppName -eq $null){ # Deploy the template -az group deployment create -g @resourceGroupName --template-file azurefunctiondeploy.json --parameters $TemplateParams + Write-Host "function not exist" + az group deployment create --resource-group $resourceGroupName --template-file azurefunctiondeploy.json --parameters appName=$functionAppName --verbose + } else{ - Write-Host "$functionAppName already exist" -} - - - - + Write-Host "function exist" +} \ No newline at end of file From 953355b2e3a3ab6836e4eef68394e57c29a2c31e Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 19:00:32 +0530 Subject: [PATCH 12/23] Update function name --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 4180dcc..0ebffd0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,7 +12,7 @@ variables: devazureSubscription: 'f27beff6-c5b7-41a5-bd50-2b9fce4760ca' # Function app name - devFunctionAppName: 'fcd-dev-web-app-abc' + devFunctionAppName: 'fcd-dev-web-app' # Agent VM image name vmImageName: 'vs2017-win2016' From b5717e29ae166be01737c3c78489443f099e0870 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 20:06:27 +0530 Subject: [PATCH 13/23] update code --- azure-pipelines.yml | 6 ++++++ config/config.ps1 | 19 +++++++++++-------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0ebffd0..557bd8e 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -14,6 +14,11 @@ variables: # Function app name devFunctionAppName: 'fcd-dev-web-app' + resourceGroupName: 'fcd-dev-function' + functionAppName: 'fcd-dev-web-app' + location: 'centralus' + templateLocation : '$(System.DefaultWorkingDirectory)/config/azurefunctiondeploy.json' + # Agent VM image name vmImageName: 'vs2017-win2016' @@ -103,6 +108,7 @@ stages: azureSubscription: 'AzureFunction' scriptType: ps scriptPath: '$(System.DefaultWorkingDirectory)/config/config.ps1' + scriptArguments: $(templateLocation) $(resourceGroupName) $(functionAppName) $(location) diff --git a/config/config.ps1 b/config/config.ps1 index 45daf72..975103f 100644 --- a/config/config.ps1 +++ b/config/config.ps1 @@ -1,12 +1,15 @@ -# Register Resource Providers if they're not already registered - -$resourceGroupName = "fcd-dev-function" -$functionAppName = "fcd-dev-web-app" +param( + [Parameter(Mandatory = $true)][String]$templateLocation, + [Parameter(Mandatory = $false)][String]$resourceGroupName = "fcd-dev-function", + [Parameter(Mandatory = $false)][String]$functionAppName = "centralus" + [Parameter(Mandatory = $false)][String]$location = "centralus" + +) # Create the parameters for the file, which for this template is the function app name. -$TemplateParams = @{"appName" = $functionAppName} - +# $TemplateParams = @{"appName" = $functionAppName} +# Register Resource Providers if they're not already registered az provider register --namespace "microsoft.web" az provider register --namespace "microsoft.storage" @@ -18,14 +21,14 @@ if($resourceExist -eq $true){ } else{ Write-Host "resources not exist" - az group create -n $resourceGroupName -l 'West Europe' + az group create -n $resourceGroupName -l $location } $checkFunctionAppName = az functionapp show -g $resourceGroupName -n $functionAppName if($checkFunctionAppName -eq $null){ # Deploy the template Write-Host "function not exist" - az group deployment create --resource-group $resourceGroupName --template-file azurefunctiondeploy.json --parameters appName=$functionAppName --verbose + az group deployment create --resource-group $resourceGroupName --template-file $templateLocation --parameters appName=$functionAppName --verbose } else{ From 33dd26efe43f03beffb62c0c29dcbe6e11f1b452 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 20:13:13 +0530 Subject: [PATCH 14/23] update --- config/config.ps1 | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/config/config.ps1 b/config/config.ps1 index 975103f..4d01306 100644 --- a/config/config.ps1 +++ b/config/config.ps1 @@ -1,10 +1,8 @@ param( [Parameter(Mandatory = $true)][String]$templateLocation, [Parameter(Mandatory = $false)][String]$resourceGroupName = "fcd-dev-function", - [Parameter(Mandatory = $false)][String]$functionAppName = "centralus" - [Parameter(Mandatory = $false)][String]$location = "centralus" - -) + [Parameter(Mandatory = $false)][String]$functionAppName = "fcd-dev-web-app", + [Parameter(Mandatory = $false)][String]$location = "centralus") # Create the parameters for the file, which for this template is the function app name. # $TemplateParams = @{"appName" = $functionAppName} From ea90398e19a063daf5ea958242319f72dc5968e8 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 20:53:14 +0530 Subject: [PATCH 15/23] update location --- config/azurefunctiondeploy.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/azurefunctiondeploy.json b/config/azurefunctiondeploy.json index fd8192f..10bbe97 100644 --- a/config/azurefunctiondeploy.json +++ b/config/azurefunctiondeploy.json @@ -115,7 +115,7 @@ "apiVersion": "2018-05-01-preview", "name": "[variables('applicationInsightsName')]", "type": "microsoft.insights/components", - "location": "East US", + "location": "[parameters('location')]", "tags": { "[concat('hidden-link:', resourceGroup().id, '/providers/Microsoft.Web/sites/', variables('applicationInsightsName'))]": "Resource" }, From a77a9fd22150c905adea3d008d14491169f315e5 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 21:49:56 +0530 Subject: [PATCH 16/23] Change the sequence --- azure-pipelines.yml | 47 +++++++++++++++++++++------------------------ 1 file changed, 22 insertions(+), 25 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 557bd8e..7f12e4f 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -12,8 +12,6 @@ variables: devazureSubscription: 'f27beff6-c5b7-41a5-bd50-2b9fce4760ca' # Function app name - devFunctionAppName: 'fcd-dev-web-app' - resourceGroupName: 'fcd-dev-function' functionAppName: 'fcd-dev-web-app' location: 'centralus' @@ -27,8 +25,29 @@ variables: testsDirectory: '$(System.DefaultWorkingDirectory)/source/tests/SampleAzureFunctionCode.Tests' stages: +- stage: Resource_Deployment + displayName: Resource Deployment + dependsOn: Start_Run_Test + condition: succeeded() + + jobs: + - job: Start_Resource_Deployment + displayName: Resources + pool: + vmImage: $(vmImageName) + + steps: + - task: AzureCLI@2 + displayName: 'Resource Deployment' + inputs: + azureSubscription: 'AzureFunction' + scriptType: ps + scriptPath: '$(System.DefaultWorkingDirectory)/config/config.ps1' + scriptArguments: $(templateLocation) $(resourceGroupName) $(functionAppName) $(location) - stage: Build displayName: Build stage + dependsOn: Resource_Deployment + condition: succeeded() jobs: - job: Build @@ -90,31 +109,9 @@ stages: testRunner: VSTest testResultsFiles: '**/*.trx' -- stage: Resource_Deployment - displayName: Resource Deployment - dependsOn: Start_Run_Test - condition: succeeded() - - jobs: - - job: Start_Resource_Deployment - displayName: Resources - pool: - vmImage: $(vmImageName) - - steps: - - task: AzureCLI@2 - displayName: 'Resource Deployment' - inputs: - azureSubscription: 'AzureFunction' - scriptType: ps - scriptPath: '$(System.DefaultWorkingDirectory)/config/config.ps1' - scriptArguments: $(templateLocation) $(resourceGroupName) $(functionAppName) $(location) - - - - stage: Dev_Deployment displayName: Dev Deployment stage - dependsOn: Resource_Deployment + dependsOn: Start_Run_Test condition: succeeded() jobs: From 1162545a6cb58bcfdc2fa605e09088386ccaa6be Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 21:52:13 +0530 Subject: [PATCH 17/23] Resolve error --- azure-pipelines.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 7f12e4f..13501c0 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -27,8 +27,6 @@ variables: stages: - stage: Resource_Deployment displayName: Resource Deployment - dependsOn: Start_Run_Test - condition: succeeded() jobs: - job: Start_Resource_Deployment From ff29a60d7236d8b1e7c9057789a00d90e7d75552 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 22:05:40 +0530 Subject: [PATCH 18/23] Resolve issues --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 13501c0..a3f9733 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -129,7 +129,7 @@ stages: inputs: azureSubscription: 'AzureFunction' appType: functionApp - appName: $(devFunctionAppName) + appName: $(functionAppName) package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip' From 33ee9a348d64a06f52da310dbbacc4df94a49b27 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Thu, 13 Feb 2020 22:48:33 +0530 Subject: [PATCH 19/23] Pass runtime language value --- config/config.ps1 | 6 +- .../config/applicationhost.config | 1027 +++++++++++++++++ 2 files changed, 1031 insertions(+), 2 deletions(-) create mode 100644 source/.vs/AzureFunctionWebAPI/config/applicationhost.config diff --git a/config/config.ps1 b/config/config.ps1 index 4d01306..d028895 100644 --- a/config/config.ps1 +++ b/config/config.ps1 @@ -2,7 +2,8 @@ param( [Parameter(Mandatory = $true)][String]$templateLocation, [Parameter(Mandatory = $false)][String]$resourceGroupName = "fcd-dev-function", [Parameter(Mandatory = $false)][String]$functionAppName = "fcd-dev-web-app", - [Parameter(Mandatory = $false)][String]$location = "centralus") + [Parameter(Mandatory = $false)][String]$location = "centralus", + [Parameter(Mandatory = $false)][String]$runtime = "dotnet") # Create the parameters for the file, which for this template is the function app name. # $TemplateParams = @{"appName" = $functionAppName} @@ -13,6 +14,7 @@ az provider register --namespace "microsoft.storage" $resourceExist = az group exists -n $resourceGroupName + if($resourceExist -eq $true){ # Create a resource group for the function app Write-Host "resources exist" @@ -26,7 +28,7 @@ $checkFunctionAppName = az functionapp show -g $resourceGroupName -n $functionAp if($checkFunctionAppName -eq $null){ # Deploy the template Write-Host "function not exist" - az group deployment create --resource-group $resourceGroupName --template-file $templateLocation --parameters appName=$functionAppName --verbose + az group deployment create --resource-group $resourceGroupName --template-file $templateLocation --parameters appName=$functionAppName runtime=$runtime --verbose } else{ diff --git a/source/.vs/AzureFunctionWebAPI/config/applicationhost.config b/source/.vs/AzureFunctionWebAPI/config/applicationhost.config new file mode 100644 index 0000000..136bd79 --- /dev/null +++ b/source/.vs/AzureFunctionWebAPI/config/applicationhost.config @@ -0,0 +1,1027 @@ + + + + + + + +
+
+
+
+
+
+
+
+ + + +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+ +
+
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+
+ + +
+
+
+
+
+
+ +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From d2d612c995d2d34c7c89e5c20ef0c82249907745 Mon Sep 17 00:00:00 2001 From: First Crazy Developer Date: Thu, 13 Feb 2020 23:18:01 +0530 Subject: [PATCH 20/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index a3f9733..0931b85 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -131,6 +131,7 @@ stages: appType: functionApp appName: $(functionAppName) package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip' + appSettings: SCM_DO_BUILD_DURING_DEPLOYMENT=true WEBSITE_RUN_FROM_PACKAGE=1 From c6943ce5c358bff4846b82fc10351d45ea0dbf20 Mon Sep 17 00:00:00 2001 From: First Crazy Developer Date: Thu, 13 Feb 2020 23:25:05 +0530 Subject: [PATCH 21/23] Update azure-pipelines.yml for Azure Pipelines --- azure-pipelines.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0931b85..edfc93b 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -131,7 +131,7 @@ stages: appType: functionApp appName: $(functionAppName) package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip' - appSettings: SCM_DO_BUILD_DURING_DEPLOYMENT=true WEBSITE_RUN_FROM_PACKAGE=1 + appSettings: "SCM_DO_BUILD_DURING_DEPLOYMENT=true WEBSITE_RUN_FROM_PACKAGE=1" From c7d340189dd88a53ad62929a0b3376ef6d8ae5ed Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 14 Feb 2020 00:04:41 +0530 Subject: [PATCH 22/23] Add app setings --- config/azurefunctiondeploy.json | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/config/azurefunctiondeploy.json b/config/azurefunctiondeploy.json index 10bbe97..4dd6fc8 100644 --- a/config/azurefunctiondeploy.json +++ b/config/azurefunctiondeploy.json @@ -25,8 +25,8 @@ }, "runtime": { "type": "string", - "defaultValue": "node", - "allowedValues": ["node", "dotnet", "java"], + "defaultValue": "dotnet", + "allowedValues": ["dotnet", "node", "java"], "metadata": { "description": "The language worker runtime to load in the function app." } @@ -106,6 +106,14 @@ { "name": "FUNCTIONS_WORKER_RUNTIME", "value": "[variables('functionWorkerRuntime')]" + }, + { + "name": "SCM_DO_BUILD_DURING_DEPLOYMENT", + "value": "true" + }, + { + "name": "WEBSITE_RUN_FROM_PACKAGE", + "value": "1" } ] } From 4d04ff5ad370a600e54ad535be90fe74cddff1f0 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 14 Feb 2020 00:05:41 +0530 Subject: [PATCH 23/23] Update App Settings --- azure-pipelines.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index edfc93b..a3f9733 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -131,7 +131,6 @@ stages: appType: functionApp appName: $(functionAppName) package: '$(Pipeline.Workspace)/drop/$(Build.BuildId).zip' - appSettings: "SCM_DO_BUILD_DURING_DEPLOYMENT=true WEBSITE_RUN_FROM_PACKAGE=1"