FIX: An error has occurred VSC deploying to Azure Functions

‘An error has occurred’ in Azure Functions is an general error message?

I’m guessing by the error message ‘an error has occurred’ in Azure Functions that this is an error message that can occur due to various issues. The tutorial below fixed it for me.
Did you find another solution? Then please share it in the comments.

I got this error in Visual Studio Code with the Azure Functions extension.


Starting Deployment, Creating Zip package, Zip package size, Error: An error has occurred…, is there more?

The complete error I got in Visual Studio Code is not very much.

20:00:17 XXXXXX: Starting deployment...
20:00:18 XXXXXX: Creating zip package...
20:00:18 XXXXXX: Zip package size: 36.3 kB
20:02:34: Error: An error has occurred.

Fortunately, there was an extensive error message in the Azure portal??

Operation name
Sync Web Apps Function Triggers
Time stamp
Wed Sep 15 2021 20:02:23 GMT+0200 (Central European Summer Time)
Event initiated by
[email protected]
Error code
BadRequest
Message
Encountered an error (InternalServerError) from host runtime.

I guess not…


Just tell me how you fixed ‘Encountered an error (InternalServerError) from host runtime.’

When I came across those error messages, they were so vague and confusing. The fact that one of them even threw an InternalServerError at me didn’t help at all. I didn’t immediately think it could be related, but then it hit me: when setting up the Function App, I remembered you also gotta link it to an Azure Storage Account.

So, guess what? Turns out, on that Storage Account, you can control access at the network level. But here’s the thing—I realized I had checked some networks without adding a virtual network. Talk about a silly mistake!

But hey, that was the problem right there! Just goes to show, sometimes the simplest things can cause the biggest issues. Lesson learned: always double-check your network settings.

'An error has occurred' Azure Functions
BadRequest Encountered an error (InternalServerError) from host runtime. ‘An error has occurred’ Azure Functions.

I’m guessing this falls under an Internal Server Error as well.

By changing this to All Networks I was able to deploy the Azure Function to Azure:

20:17:59 XXXXXX: Starting deployment...
20:18:00 XXXXXX: Creating zip package...
20:18:01 XXXXXX: Zip package size: 36.3 kB
20:18:05 XXXXXX: Updating submodules.
20:18:05 XXXXXX: Preparing deployment for commit id '273c65340d'.
20:18:06 XXXXXX: Skipping build. Project type: Run-From-Zip
20:18:06 XXXXXX: Skipping post build. Project type: Run-From-Zip
20:18:06 XXXXXX: Triggering recycle (preview mode disabled).
20:18:14 XXXXXX: Deployment successful.
20:18:26 XXXXXX: Syncing triggers...
20:18:36 XXXXXX: Querying triggers...
20:18:38 XXXXXX: WARNING: Some http trigger urls cannot be displayed in the output window because they require an authentication token. Instead, you may copy them from the Azure Functions explorer.

I choose All Networks because this is in a test environment. In production I would test with different settings.

Published by

Bas Wijdenes

My name is Bas Wijdenes and I work as a PowerShell DevOps Engineer. In my spare time I write about interesting stuff that I encounter during my work.

One thought on “FIX: An error has occurred VSC deploying to Azure Functions”

Leave a Reply

Your email address will not be published. Required fields are marked *