How do I transfer a Azure Function script to Visual Studio? - azure

If I create an Azure Function in the Azure portal, how do I grab the script and edit it in Visual Studio? I know I can copy the C# code from the script window but that's only part of the Function. How do I grab everything - the code, triggers, outputs, etc. - and take that into Visual Studio?

There's a button right in the Function App blade in Azure that allows you to download the contents of the function app:
You can even choose to download the Content and the Visual Studio project so you can directly import it into VS. However, as Travis mentioned you should really be doing this the other way around and keeping your development in VS and then using one of the various deployment options to push your functions to Azure.

You can use FTP or Kudu(.scm.azurewebsites.net) to download the app contents.
Generally speaking though if you want to work in Visual Studio it's better to do your work there and then deploy to the app with one of the several deployment options.

Once your migrate the files (as noted in the other answers), you'll also note that Visual Studio encourages a different programming model than the portal:
Precompile *.cs instead of .csx
Instead of Function.json, you use the attributes (ala WebJobs SDK).
So to fully work in VS and leverage the VS build system (and unit tests, and other VS features), you'll need to migrate your code.
See https://blogs.msdn.microsoft.com/webdev/2017/05/10/azure-function-tools-for-visual-studio-2017/ for more detail on webjobs.

Related

Azure functions not showing under "Add new item" in visual studio 2022

I'm learning Azure functions, and after setting up an initial project the tutorial suggests to select Project > Add new Item > Azure function.
On my end, I don't see Add New Item in the menu, but if I right click on the .csproj file I see add new item, however, I don't see an option for adding an azure function.
Expected behavior (screenshot from tutorial)
Actual behavior on my end:
I checked this post where it says to add "Azure Functions and web job tools" though I don't see that as an option on my side.
Also referenced this post:
Missing Azure functions template under Add new item in Visual Studio
It recommended making sure I have the Azure SDK workload (which I do) and installing this SDK: Microsoft.Net.Sdk.Functions
I went to my folder and ran this command so as far as I know it's installed at this point.
dotnet add package Microsoft.NET.Sdk.Functions --version 4.1.3
This is my current file structure and .csproj file.
When setting up VS, I selected Azure SDK as a workload. Also, if I go to File > New > Project, I have an option for Azure functions.
Any insight as to why it's not showing up for me would be appreciated. If you need me to clarify anything, please let me know.
As you have followed one of my practical workarounds #7004818, make sure you have done the below configuration:
Download & Install the Azure Functions Core Tools, VS 2022 Current Version 17.4.4
In Visual Studio installer, Select the below options:
- Web & Cloud: ASP .NET & Web development, Azure Development
- Desktop & Mobile: .NET Desktop development
- Other toolsets: Visual Studio Extension Development
You are developing the Azure Functions in .NET So, install the respective Version SDK & Runtime.
On the Same above Post, the user #GraceA added a point to my answer which is to check the NuGet Package Source Install/Update is missing and there are steps given in the answer for updating/installing it.
[VS NuGet Package Update Gif Image1]
[VS Azure Functions Toolset Update Gif Image 2]
The Same issue registered on MS Q&A Forum #386611 where the user has resolved it by updating the NuGet Package Source.

How to use makeappx to create msixbundle files that can be uploaded to the store according to the appxmanifest file?

For some reason(about the digital signature of the desktop bridge app, see here), I can't use visual studio to package my project. Makeappx seems to be able to do this, but those commands are too complex for me. Is there an easier way to achieve this?
Or to put it another way, how can I directly refer to the EXE file (which I can sign) rather than just the project in the application package project?
If Visual Studio is too complicated I recommend you get the free Express edition from Advanced Installer.
In the link include you can find a video that shows how to build an MSIX package (for bundle just change the radio button option from Builds page).
Additional info -
Publishing an MSIX package in the MS store.
Disclaimer: I work on the team building Advanced Installer.

Use Azure CLI to generate function class library

I've noticed I generate a different folder structure and file extensions for C# code depending on whether I use the the Azure CLI (folder with a .csx script library) or Visual studio (no folder with a .cs class library). Debugging from the CLI only exposes the .csx endpoints and visa-versa from Visual Studio.
Is it possible to configure the Azure CLI to generate functions using class libraries? Or so that the CLI and Visual Studio provide the same debugging endpoints?
It's not possible now. We have few asks for it and will add it at some point, issue to track:
https://github.com/Azure/azure-functions-core-tools/issues/382

Publish app to Azure from VS Code

Is there a way to publish an app from Visual Studio Code to Azure App service directly i.e. without going through Git or some other source control?
No, there is no native way of doing so. You can créate a Task in Visual Studio code that does the git push or ftp push or something. But no native way yet.
Actually, now it is possible: see this.
But for now I would discourage you from using VS Code to deploy on Azure through the official extension, I'm facing plenty of errors and wasting tons of hours, even trying to publish a default basic MVC template: errors 404, 403, 500 ("Cannot find compilation library location for package 'Microsoft.NETCore.App'")... it's a nightmare. It's even more unpleasant since they're all made by Microsoft, and they just don't work together.
Using the classical Visual Studio should work well.

TFS Build - Publish specific build from drop folder

We currently use TFS to deploy builds to our servers in different environments such as QA, PreProd and Prod. In the current method, the build agent gets all latest from TFS, builds and publishes to whichever environment specified.
I know that you can actually just publish just to a drop folder where it creates PublishedWebsites folder, but how can you publish to servers from drop folder mentioning specific build? For example, there may be build #7, which our QA team has certified. We want to make sure that that is the build that is going to production and not latest content which might have some check ins from other team members.
Any help would be appreciated. I referred this link, but it is mentioning about overriding OutputRoot directory in publish.proj file, which is not created in the solution that we created using Visual Studio 2012.
http://www.asp.net/web-forms/tutorials/deployment/configuring-team-foundation-server-for-web-deployment/deploying-a-specific-build
You have multiple way of solving the needs.
The best option is to use LabManagement; it will take care of computing the correct Drop folder. See Using a Lab Environment for Your Application Lifecycle for details. The idea is to use the build-deploy-test workflow to deploy and run tests on a group of machines running Test Agent.
You can setup a more sophisticated process using Release Management, a new feature of TFS 2013 that you can add to 2012 as well. It offers to design your promotion process and control who authorizes deployments.
You should neither use Build or Lab Management to do deployments. Both are poor solutions for this as this is not what they were designed for.
Microsoft added a dedicated release management tool with visual studio 2013. I have configured and used it with both 2012 & 2013.
http://nakedalm.com/building-release-pipeline-release-management-visual-studio-2013/
This will be much easier than either of the other tools.

Resources