Azure / Azure-Functions

1.12k stars 198 forks source link

Issues with deploying durable function app via ARM template. No host keys, errors. #1537

Closed shortboard closed 3 years ago

shortboard commented 4 years ago

Hi,

I've been trying to deploy a durable functions app to Azure through an ARM template but when I deploy it does not generate any host keys and and throws errors when I navigate around the portal, for example I encounter Error: Encountered an error (InternalServerError) from host runtime when navigating to the Function App Settings page.

When deploying directly from Visual Studio I don't encounter any of these errors.

When I look into Application Insights i can see that the following exception has been thrown:

The BlobChangeAnalysisStateProvider requires the default storage account 'Storage', which is not defined. 
System.InvalidOperationException:
   at Microsoft.Azure.WebJobs.Script.ChangeAnalysis.BlobChangeAnalysisStateProvider+<GetCurrentAsync>d__5.MoveNext (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\BreakingChangeAnalysis\BlobChangeAnalysisStateProvider.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 37)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Script.ChangeAnalysis.ChangeAnalysisService+<TryLogBreakingChangeReportAsync>d__12.MoveNext (Microsoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\BreakingChangeAnalysis\ChangeAnalysisService.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null: 92)

But googling around i can't seem to find a resolution to this, and i'm not sure what i need to change to make it work.

For reference here is my ARM Template:

{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "type": "string"
        },
        "prefix": {
            "type": "string"
        },
        "suffix": {
            "type": "string",
            "defaultValue": ""
        },
        "ProvisioningFunctionsName": {
            "defaultValue": "[concat(parameters('prefix'), '-ProvisioningFunctions', parameters('suffix'))]",
            "type": "String"
        },
         "consumptionPlanName": {
            "type": "string",
            "defaultValue": "[concat(parameters('prefix'), '-Consumption-Plan', parameters('suffix'))]"
        },
        "storageAccountName": {
            "type": "string",
            "defaultValue": "[concat(parameters('prefix'), '-ProvisioningStorage', parameters('suffix'))]"
        }
    },
    "variables": {
        "storageAccountName": "[toLower(concat(substring(replace(parameters('storageAccountName'),'-',''),0,18), take(uniqueString(resourceGroup().id),6)))]",
        "funcEndpoint": "[concat('https://', toLower(parameters('ProvisioningFunctionsName')), '.azurewebsites.net')]"
    },
    "resources": [
        {
            "type": "microsoft.insights/components",
            "apiVersion": "2015-05-01",
            "name": "[parameters('ProvisioningFunctionsName')]",
            "location": "[parameters('location')]",
            "kind": "web",
            "properties": {
                "Application_Type": "web"
            }
        },
         {
            "type": "Microsoft.Storage/storageAccounts",
            "apiVersion": "2019-06-01",
            "name": "[variables('storageAccountName')]",
            "location": "[parameters('location')]",
            "sku": {
                "name": "Standard_LRS",
                "tier": "Standard"
            },
            "kind": "Storage",
            "properties": {
                "networkAcls": {
                    "bypass": "AzureServices",
                    "virtualNetworkRules": [
                    ],
                    "ipRules": [
                    ],
                    "defaultAction": "Allow"
                },
                "supportsHttpsTrafficOnly": true,
                "encryption": {
                    "services": {
                        "file": {
                            "keyType": "Account",
                            "enabled": true
                        },
                        "blob": {
                            "keyType": "Account",
                            "enabled": true
                        }
                    },
                    "keySource": "Microsoft.Storage"
                }
            }
        },
        {
            "type": "Microsoft.Web/sites",
            "apiVersion": "2018-11-01",
            "name": "[parameters('ProvisioningFunctionsName')]",
            "location": "[parameters('location')]",
            "kind": "functionapp",
            "properties": {
                "enabled": true,
                "hostNameSslStates": [
                    {
                        "name": "[variables('funcEndpoint')]",
                        "sslState": "Disabled",
                        "hostType": "Standard"
                    },
                    {
                        "name": "[variables('funcEndpoint')]",
                        "sslState": "Disabled",
                        "hostType": "Repository"
                    }
                ],
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('consumptionPlanName'))]",
                "httpsOnly": true,
                "siteConfig": {
                    "appSettings": [
                        {
                            "name": "AzureWebJobStorage",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts',variables('storageAccountName')),'2015-05-01-preview').key1, ';EndpointSuffix=core.windows.net')]"
                        },
                        {
                            "name": "AzureWebJobDashboard",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts',variables('storageAccountName')),'2015-05-01-preview').key1, ';EndpointSuffix=core.windows.net')]"
                        },
                        {
                            "name": "FUNCTIONS_EXTENSION_VERSION",
                            "value": "~3"
                        },
                        {
                            "name": "FUNCTIONS_WORKER_RUNTIME",
                            "value": "dotnet"
                        },
                        {
                            "name": "WEBSITE_CONTENTAZUREFILECONNECTIONSTRING",
                            "value": "[concat('DefaultEndpointsProtocol=https;AccountName=', variables('storageAccountName'), ';AccountKey=', listKeys(resourceId('Microsoft.Storage/storageAccounts',variables('storageAccountName')),'2015-05-01-preview').key1, ';EndpointSuffix=core.windows.net')]"
                        },
                        {
                            "name": "WEBSITE_CONTENTSHARE",
                            "value": "[ToLower(parameters('ProvisioningFunctionsName'))]"
                        },
                        {
                            "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                            "value": "[reference(resourceId('microsoft.insights/components/', parameters('ProvisioningFunctionsName')), '2015-05-01').InstrumentationKey]"
                        },
                        {
                            "name": "WEBSITE_RUN_FROM_PACKAGE",
                            "value": "1"
                        }
                    ]
                }
            }
        },
        {
            "type": "Microsoft.Web/sites/hostNameBindings",
            "apiVersion": "2018-11-01",
            "name": "[concat(parameters('ProvisioningFunctionsName'), '/', parameters('ProvisioningFunctionsName'), '.azurewebsites.net')]",
            "location": "[parameters('location')]",
            "dependsOn": [
                "[resourceId('Microsoft.Web/sites', parameters('ProvisioningFunctionsName'))]"
            ],
            "properties": {
                "siteName": "[parameters('ProvisioningFunctionsName')]",
                "hostNameType": "Verified"
            }
        }
    ]
}
fusionet24 commented 4 years ago

@shortboard did you find out in the end? Having this issue publishing from Visual Studio at the moment. No idea what is wrong.

vllama commented 4 years ago

This seems to be broken for me as well. Did you figure this out. All my functions have stopped working. I see this error in appinsights

System.InvalidOperationException:
   at Microsoft.Azure.WebJobs.Script.ChangeAnalysis.BlobChangeAnalysisStateProvider+<GetCurrentAsync>d__5.MoveNext (Microsoft.Azure.WebJobs.Script.WebHost, Version=2.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\BreakingChangeAnalysis\BlobChangeAnalysisStateProvider.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null: 37)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Script.ChangeAnalysis.ChangeAnalysisService+<TryLogBreakingChangeReportAsync>d__12.MoveNext (Microsoft.Azure.WebJobs.Script.WebHost, Version=2.0.0.0, Culture=neutral, PublicKeyToken=nullMicrosoft.Azure.WebJobs.Script.WebHost, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null: D:\a\1\s\src\WebJobs.Script.WebHost\BreakingChangeAnalysis\ChangeAnalysisService.csMicrosoft.Azure.WebJobs.Script.WebHost, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null: 92)

Microsoft.Azure.WebJobs.Host.Listeners.FunctionListenerException:
System.FormatException:
   at Microsoft.WindowsAzure.Storage.CloudStorageAccount+<>c.<Parse>b__97_0 (Microsoft.WindowsAzure.Storage, Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at Microsoft.WindowsAzure.Storage.CloudStorageAccount.ParseStringIntoSettings (Microsoft.WindowsAzure.Storage, Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at Microsoft.WindowsAzure.Storage.CloudStorageAccount.ParseImpl (Microsoft.WindowsAzure.Storage, Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at Microsoft.WindowsAzure.Storage.CloudStorageAccount.Parse (Microsoft.WindowsAzure.Storage, Version=9.3.1.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at Microsoft.Azure.WebJobs.Extensions.Timers.StorageScheduleMonitor.get_TimerStatusDirectory (Microsoft.Azure.WebJobs.Extensions, Version=3.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Extensions, Version=3.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\azure-webjobs-sdk-extensions\src\WebJobs.Extensions\Extensions\Timers\Scheduling\StorageScheduleMonitor.csMicrosoft.Azure.WebJobs.Extensions, Version=3.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 77)
   at Microsoft.Azure.WebJobs.Extensions.Timers.StorageScheduleMonitor.GetStatusBlobReference (Microsoft.Azure.WebJobs.Extensions, Version=3.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Extensions, Version=3.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\azure-webjobs-sdk-extensions\src\WebJobs.Extensions\Extensions\Timers\Scheduling\StorageScheduleMonitor.csMicrosoft.Azure.WebJobs.Extensions, Version=3.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 144)
   at Microsoft.Azure.WebJobs.Extensions.Timers.StorageScheduleMonitor+<GetStatusAsync>d__10.MoveNext (Microsoft.Azure.WebJobs.Extensions, Version=3.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Extensions.Timers.Listeners.TimerListener+<StartAsync>d__27.MoveNext (Microsoft.Azure.WebJobs.Extensions, Version=3.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Extensions, Version=3.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\azure-webjobs-sdk-extensions\src\WebJobs.Extensions\Extensions\Timers\Listener\TimerListener.csMicrosoft.Azure.WebJobs.Extensions, Version=3.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 99)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Host.Listeners.SingletonListener+<StartAsync>d__13.MoveNext (Microsoft.Azure.WebJobs.Host, Version=3.0.16.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.16.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Singleton\SingletonListener.csMicrosoft.Azure.WebJobs.Host, Version=3.0.16.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 70)
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult (System.Private.CoreLib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e)
   at Microsoft.Azure.WebJobs.Host.Listeners.FunctionListener+<StartAsync>d__13.MoveNext (Microsoft.Azure.WebJobs.Host, Version=3.0.16.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35Microsoft.Azure.WebJobs.Host, Version=3.0.16.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: C:\projects\azure-webjobs-sdk-rqm4t\src\Microsoft.Azure.WebJobs.Host\Listeners\FunctionListener.csMicrosoft.Azure.WebJobs.Host, Version=3.0.16.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35: 68)
vllama commented 4 years ago

For anyone still having this issue:, got this to work by omitting : WEBSITE_CONTENTSHARE.

It generated its own with a custom name composed of the function_name- a random suffix

It also created the share in the storage specified by : WEBSITE_CONTENTAZUREFILECONNECTIONSTRING

Cheers, V

melix-dev commented 4 years ago

I do see a typo in the ARM template: AzureWebJobStorage should be AzureWebJobsStorage (it was missing the 's') in the appSettings element

jainshikha commented 4 years ago

i do face the same issue after providing "AzureWebJobsStorage " in local json trying to do dockerization of azurefunction. please let me know if there is a solve for this.

balag0 commented 4 years ago

The exception "The BlobChangeAnalysisStateProvider requires the default storage account 'Storage', which is not defined. " usually means either the appsetting 'AzureWebJobsStorage' is missing or set to some invalid storage connection string.

If you are still seeing an error, please provide the correlation id and timestamp. Also does the app start working if you wait for a while or restart it (just to rule out some race condition) or does the app stay broken?

v-bbalaiagar commented 3 years ago

Can we understand if this issue require further triaging or is good to be closed?

shortboard commented 3 years ago

I think I eventually solved my issue (not on this particular template but in a future one) and if my memory serves correctly it was to do with the version of the storage account that I was creating.

v-bbalaiagar commented 3 years ago

Hi @shortboard, Let us know if this can be closed as resolved, or if you have any further queries.

v-bbalaiagar commented 3 years ago

Closing this issue as resolved. please feel free to reach back to us in case of any further queries related to this issue.