在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
Using C# with Azure FunctionsTwo important prerequisites need to be met to build Azure Functions applications with C#:
As a C# developer, you are already familiar with the various tools for building your applications which include Visual Studio Code and Visual Studio IDE. Both tools help create applications with Azure Functions, depending on whichever one you are most comfortable with. Let’s dig a little deeper into these two tools: Visual Studio CodeVisual Studio Code is a lightweight but powerful code editor with different versions available for Windows, Linux, and MacOS. To build apps for Azure functions, you will need to get Azure Tools for Visual Studio Code which will give you convenient commands through which you can access or create resources directly from the VS Code editor. To set up Azure Tools, install the Azure Extension Pack by firing up your editor and navigating to the extension marketplace on the left side menu. The extension marketplace interface in VS Code should look like this: When you are done with the setup of Azure for VS Code, login to Azure from the code editor by firing the Command Palette with the commands CTRL+Shift+P and typing “Azure: Login” in the text field that appears. Click the corresponding result that appears and a code will be generated by the editor with instructions on how to complete the process. Another important extension if you will be developing in C# with VS Code is the C# for Visual Studio Code. As at the time of this writing, the extension supports basic debugging capabilities full details of which can be found here. Visual Studio 2017 IDEFrom version 15.5, Azure Development workload comes bundled with Azure Functions tools. This implies if you plan on installing the latest version of Visual Studio 2017, you need to include Azure Development workload in your installation process. Your installation window should look like this: Once installation is complete, sign in to your Microsoft account in Visual Studio and create a new Azure Functions project and you are good to go. Now that we’ve highlighted what you need to know if you want to build serverless functions in C# with Azure functions, let’s move over to discussing what you need to begin running serverless apps on the AWS Lambda serverless framework. Using C# with AWS LambdaAWS Lambda is the compute part of the AWS serverless architecture, but contains zero administration. It is one of the most popular options for serverless and though it was launched by AWS in 2014, support for the .NET Core 1.0 runtime was announced in 2016 and the .NET Core 2.0 runtime in 2018. At this point, it is important to note .NET Core is different from the .NET framework and here are a few reasons AWS chose .NET Core over the .NET framework:
To begin building Lambda functions in C# with Visual Studio you will need to understand AWS Lambda has a laid-down pattern for authoring code for your Lambda function. This pattern includes the following concepts:
Now that we know the framework for writing for AWS Lambda, let’s see how all this work together. Writing C# Code for AWS Lambda with Visual StudioA few prerequisites are required to begin writing code for Lambda functions:
Note: older versions of Visual Studio will require an additional installation of .NET Core for Windows
Once you’ve installed all prerequisites, open Visual Studio and fill in the AWS credentials on the Getting Started with the AWS Toolkit for Visual Studio window displayed next to the Start Page tab. The credentials (Access Key and Secret Key) can be gotten by following the instructions outlined in the window With that all set, let’s move on to build our Lambda project. Create a .NET Core Lambda Project
Publishing to AWS LambdaThe next step to running our code on AWS Lambda is to publish it. This is done after the code has been reviewed and you are convinced it is good to go. The following steps outline what you need to do to get your code published.
ConclusionNow, you have a quick peek into what you need to know to build and publish serverless applications with the powerful C# programming language. Though at Dashbird, we are more inclined towards AWS Lambda, there is nothing stopping you from exploring both the Microsoft Azure functions and AWS Lambda options in getting that serverless infrastructure for your applications. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论