Reputation: 63
I've been trying to get my Linux Function App running, but I've been stuck with this error now:
Microsoft.Azure.WebJobs.Script: Error building configuration in an external startup class. Microsoft.Azure.WebJobs.Extensions.FunctionMetadataLoader: The file '/home/site/wwwroot/MyVsProjectName' was not found.
I can see all my project dlls and assets in /home/site/wwwroot/ yet this error keeps claiming that there should be a folder or file with my project name there?
My project is running using dotnet 6 isolated.
Any ideas why this FunctionMetadataLoader is looking for this file/folder? I checked similar Windows apps that I've deployed and they all have files directly in wwwroot.
This app is running within a Linux OS, I1 tier asp. And it release from CICD in Azure DevOps Zip Deploy.
Here is part of my arm template for the Function App.
"resources": [
{
"apiVersion": "2021-04-01",
"type": "Microsoft.Resources/deployments",
"name": "[concat(parameters('appServiceName'), '-deployment','-', uniqueString(guid('any')))]",
"dependsOn": [],
"resourceGroup": "[parameters('appServiceResourceGroup')]",
"properties": {
"mode": "Incremental",
"template": {
"$schema": "http://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"variables": {},
"resources": [
{
"apiVersion": "2018-11-01",
"name": "[parameters('appServiceName')]",
"type": "Microsoft.Web/sites",
"location": "[parameters('location')]",
"kind": "functionapp,linux",
"tags": {
"environment": "[parameters('environmentTag')]",
"monitor": "[parameters('monitorTag')]",
"owner": "[parameters('ownerTag')]",
"workload": "[parameters('workloadTag')]",
"serviceLine": "[parameters('serviceLineTag')]",
"system": "[parameters('systemTag')]",
"initiatingEpic": "[parameters('initiatingEpicTag')]",
"dr": "[parameters('drTag')]",
"notes": "[parameters('notesTag')]"
},
"identity": {
"type": "UserAssigned",
"userAssignedIdentities": {
"[resourceId(parameters('appServiceResourceGroup'),'Microsoft.ManagedIdentity/userAssignedIdentities/',parameters('managedIdentityName'))]": {}
}
},
"properties": {
"name": "[parameters('appServiceName')]",
"httpsOnly": true,
"reserved": true,
"isXenon": false,
"hyperV": false,
"siteConfig": {
"use32BitWorkerProcess": false,
"minTlsVersion": "1.2",
"ftpsState": "Disabled",
"http20Enabled": true,
"netFrameworkVersion": "v6.0",
"linuxFxVersion": "DOTNET-ISOLATED|6.0",
"appSettings": [
{
"name": "APPINSIGHTS_INSTRUMENTATIONKEY",
"value": "[reference(variables('appInsightsResourceId'), variables('appInsightsApiVersion'), '2016-03-01').instrumentationKey]"
},
{
"name": "APPLICATIONINSIGHTS_CONNECTION_STRING",
"value": "[reference(variables('appInsightsResourceId'), variables('appInsightsApiVersion'), '2016-03-01').ConnectionString]"
},
{
"name": "ApplicationInsightsAgent_EXTENSION_VERSION",
"value": "~2"
},
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~4"
},
{
"name": "FUNCTIONS_WORKER_RUNTIME",
"value": "dotnet-isolated"
},
{
"name": "AzureWebJobsStorage",
"value": "[parameters('storageAccountConnection')]"
},
{
"name": "AzureFunctionsWebHost__hostId",
"slotSetting": false,
"value": ""
},
{
"name": "WEBSITE_RUN_FROM_PACKAGE",
"slotSetting": false,
"value": "0"
}
],
"connectionStrings": [],
"alwaysOn": true
},
"keyVaultReferenceIdentity": "[resourceId(parameters('appServiceResourceGroup'),'Microsoft.ManagedIdentity/userAssignedIdentities/',parameters('managedIdentityName'))]",
"clientAffinityEnabled": false,
"serverFarmId": "[resourceId(parameters('serverFarmResourceGroup'),'Microsoft.Web/serverFarms',parameters('appServicePlanName'))]",
"hostingEnvironment": "[parameters('appServiceEnvironmentName')]"
}
}
]
}
}
}
]
Project File:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<_FunctionsSkipCleanOutput>true</_FunctionsSkipCleanOutput>
<PublishReadyToRun>true</PublishReadyToRun>
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.10.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Warmup" Version="4.0.2" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.ServiceBus" Version="5.7.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.7.0" OutputItemType="Analyzer">
<TreatAsUsed>true</TreatAsUsed>
</PackageReference>
<PackageReference Include="Microsoft.FeatureManagement.AspNetCore" Version="2.5.1" />
<PackageReference Include="Serilog.AspNetCore" Version="6.1.0" />
</ItemGroup>
<ItemGroup>
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Upvotes: 0
Views: 1225
Reputation: 8195
I tried deploying .Net 6.0 Isolated Function
with Function App via ARM template in Azure DevOps and it ran successfully, Refer below:-
My ARM template code using source control parameter referred to my github Function code repository:-
functionapp.json
You can try this ARM Template for testing.
Below ARM template reference from my SO thread answer Refer my answer for more clarity on deploying Function app and Trigger with ARM template.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"appName": {
"defaultValue": "[concat('funtionapp-', uniqueString(resourceGroup().id))]",
"type": "string",
"metadata": {
"description": "The name of the function app that you wish to create."
}
},
"sku": {
"defaultValue": "S1",
"type": "string",
"metadata": {
"description": "The pricing tier for the hosting plan."
}
},
"workerSize": {
"defaultValue": "0",
"allowedValues": [
"0",
"1",
"2"
],
"type": "String",
"metadata": {
"description": "The instance size of the hosting plan (small, medium, or large)."
}
},
"storageAccountType": {
"defaultValue": "Standard_LRS",
"allowedValues": [
"Standard_LRS",
"Standard_GRS",
"Standard_ZRS",
"Premium_LRS"
],
"type": "string",
"metadata": {
"description": "Storage Account type"
}
},
"repoURL": {
"defaultValue": "https://github.com/sid24desai/FunctionApp49",
"type": "string",
"metadata": {
"description": "The URL for the GitHub repository that contains the project to deploy."
}
},
"branch": {
"defaultValue": "master",
"type": "string",
"metadata": {
"description": "The branch of the GitHub repository to use."
}
},
"location": {
"defaultValue": "[resourceGroup().location]",
"type": "string",
"metadata": {
"description": "Location for all resources."
}
}
},
"variables": {
"functionAppName": "[parameters('appName')]",
"hostingPlanName": "[concat(parameters('appName'), '-plan')]",
"storageAccountName": "[concat(uniquestring(resourceGroup().id), 'functions')]"
},
"resources": [
{
"type": "Microsoft.Storage/storageAccounts",
"apiVersion": "2021-02-01",
"name": "[variables('storageAccountName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('storageAccountType')]"
},
"kind": "Storage"
},
{
"type": "Microsoft.Web/serverfarms",
"apiVersion": "2020-12-01",
"name": "[variables('hostingPlanName')]",
"location": "[parameters('location')]",
"sku": {
"name": "[parameters('sku')]"
},
"properties": {
"workerSize": "[parameters('workerSize')]",
"numberOfWorkers": 1
}
},
{
"type": "Microsoft.Web/sites",
"apiVersion": "2020-12-01",
"name": "[variables('functionAppName')]",
"location": "[parameters('location')]",
"dependsOn": [
"[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"[resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName'))]"
],
"kind": "functionapp",
"properties": {
"name": "[variables('functionAppName')]",
"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', variables('hostingPlanName'))]",
"clientAffinityEnabled": false,
"siteConfig": {
"alwaysOn": true,
"cors": {
"allowedOrigins": [
"*"
]
},
"appSettings": [
{
"name": "FUNCTIONS_EXTENSION_VERSION",
"value": "~v4"
},
{
"name": "AzureWebJobsStorage",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value,';')]"
},
{
"name": "AzureWebJobsDashboard",
"value": "[concat('DefaultEndpointsProtocol=https;AccountName=',variables('storageAccountName'),';AccountKey=',listkeys(resourceId('Microsoft.Storage/storageAccounts', variables('storageAccountName')), '2019-06-01').keys[0].value,';')]"
}
]
}
},
"resources": [
{
"type": "sourcecontrols",
"apiVersion": "2020-12-01",
"name": "web",
"dependsOn": [
"[resourceId('Microsoft.Web/Sites', variables('functionAppName'))]"
],
"properties": {
"RepoUrl": "[parameters('repoURL')]",
"branch": "[parameters('branch')]",
"IsManualIntegration": true
}
}
]
}
]
}
My Azure Devops repository:-
My Build yaml pipeline:-
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- task: AzureResourceManagerTemplateDeployment@3
displayName: 'ARM Template deployment: Resource Group scope'
inputs:
deploymentScope: 'Resource Group'
azureResourceManagerConnection: 'xxx subscription(xxxxd6-b4fd-e2xxxx)'
subscriptionId: 'xxxxxxxxx2a7'
action: 'Create Or Update Resource Group'
resourceGroupName: 'valleyrg103'
location: 'Australia East'
templateLocation: 'Linked artifact'
csmFile: '$(System.DefaultWorkingDirectory)/functionapp.json'
deploymentMode: 'Incremental'
Output:-
Make sure you add this https://portal.azure.com
in the CORS setting like below:-
Function app with .net 6.0 Isolated Function got deployed and is running successfully refer below:-
Same Deployment with Release pipeline using ARM Template deployment: Resource Group scope task :-
Output:-
Upvotes: 0