Search code examples
azure-functionsazure-virtual-network

Azure Function App deployment fails because Virtual network associated with the link cannot be changed


tl;dr: I have created one function app with private endpoints and vnet, but creating and deploying another fails because Virtual network associated with the link cannot be changed

Longer question:

I have created a Python 3.10 Function App with this instruction from Azure (up until Service Bus, just the Function App). I used the Elastic Premium plan in order to use Vnet and Private Endpoints. It works great!

However, I need to create another Function app in the same fashion, and when I try, I get the error enter image description here

{ "status": "Failed", "error": { "code": "BadRequest", "message": "Virtual network associated with the link cannot be changed." } }

The error is the same for each one. I have tried several times, but the end result is the same. The function app technically still works, even though the deployment failed, but the FA loses access to the storage account if I change the storage account's network settings to only accept certain networks, even if the private vnet is configured for the storage account. (In the working FA, I can do whatever I want to the storage account's settings, and FA will still have access to it because of the vnet and the private endpoints).

Can I only have one elastic premium function app at the same time?

I'm willing to create a web app instead of a function app for my other use, but it will also require endpoints and the vnet, so I think I will encounter the same issue there.

(I saw this person had the same problem, but they didn't get an answer, and stackoverflow says I need 50 reputation points to comment there)


Solution

  • { "status": "Failed", "error": { "code": "BadRequest", "message": "Virtual network associated with the link cannot be changed." } }

    • The error Virtual network associated with the link cannot be changed occurs if you are trying to change the virtual network associated with the Function App.
    • This could also be due to the virtual network is associated with the Premium plan because each Premium plan can only be associated with one virtual network.

    I tried your requirement with multiple scenarios:

    1. Created function apps with same hosting plan, different storage account and the same virtual network.
    2. Created function apps with same hosting plan, same storage account and the same virtual network.
    3. Created function apps with different hosting plan, same storage account and the same virtual network.

    When tried with scenarios 1 and 2, I was getting the same error:

    enter image description here

    However when I tried to create the another function app a new hosting plan (premium plan), same storage account and the same virtual network, I was able to create the function app without any conflicts.

    Function App 1:

    enter image description here

    Function App 2:

    enter image description here

    • If you are using the same storage account for the new function app, there is no need of configuring new storage private end point links.
    • If you try to use different/new storage account while creating the second function app, it will ask to create new storage private endpoint link.

    enter image description here

    So, to create another Function App with the same VNet configuration and private endpoints, you have to create a new hosting plan(Premium) with the same Virtual Network.