简体   繁体   中英

Deploying a single Azure Function from Visual studio

I have a question regarding Azure functions, when deploying azure functions in the same project you have to deploy all at once, you cant deploy a single function within the same project from VS to Azure.

Is there any way to do this or do each function have to be within its own project to deploy one function at a time to Azure?

This would make them their own resources then too i would guess. or?

Have a look at official guideline .

In most scenarios, the unit of deployment should be the Function App, and not individual functions. Deploying a Function App is essentially identical to deploying a Web App

If functions in the same project don't rely on each other and we don't want to deploy them together, we could just split them to separate projects and deploy each project to different Function app. As for resources, there's not so much difference between one and multiple Function Apps as long as they share the same App service plan.

The risk of deploying a single function to Function app which has existing functions

Technically we could deploy single function from VS, simply right click and exclude functions we don't need to deploy. This is absolutely right and safe if the Function app is still empty or we have checked Remove additional files at destination (should be checked by default).

删除文件

If we uncheck that setting in order to retain those functions deployed before, it could lead to inconsistent behavior. The newly deployed function may overwrite some assemblies which are leveraged by existing functions. Also, useless files that we delete locally could accumulate online due to the lack of deletion.

From Visual Studio, you will have to have Publish settings for each function. To deploy each function, you will have to amend "hosts.json" file like

{
  "functions": [
    "QueueFunction",
    "ProcessorFunction",
  ]
}

you can have 1 function or many functions. if you leave this empty, all functions will be deployed.

I would recommend you to have DevOps build & deploy to help you out; alternatively, separate project for each function to avoid deployment complexities, with all common objects as another shared project.

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM