博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
vs 部署 azure_使用VS Code的Azure函数入门:零部署
阅读量:2512 次
发布时间:2019-05-11

本文共 9619 字,大约阅读时间需要 32 分钟。

vs 部署 azure

This article was co-authored by . He’s a freelance developer evangelist and concatenate.io conference volunteer.

本文 合着 他是一名自由职业的开发人员和concatenate.io会议志愿者。

Azure Functions is a compute service that enables you to run code on demand without having to explicitly provision or manage infrastructure. In this tutorial, we are going to get you started on Azure Functions from the bare minimum. We’ll walk you through the installation processes with Visual Studio Code, create your first Function App and finally deploying that app to Azure.

Azure Functions是一种计算服务,使您可以按需运行代码,而不必显式设置或管理基础结构。 在本教程中,我们将使您从最低限度开始使用Azure Functions。 我们将指导您使用Visual Studio Code进行安装过程,创建您的第一个Function App,最后将其部署到Azure。

Prerequisites First off, you’ll need an Azure account, . You will also need to have installed along with , the Node.js package manager. To enable local debugging, you also need to install the . For the scope of this tutorial, we only require that you have VSCode, Node and Npm installed — we’ll walk you through the rest.

先决条件首先,您需要一个Azure帐户 。 您还需要同时安装 , Node.js程序包管理器 。 若要启用本地调试,还需要安装 。 在本教程的范围内,我们仅要求您安装VSCode,Node和Npm-我们将引导您完成其余的步骤。

Creating an Azure account This is very much the first step. To create an Azure account, go to the Azure registration page and

创建一个Azure帐户这是第一步。 若要创建一个Azure帐户,请转到“ Azure注册”页面并

Click on the Start Free button to register for a free account or buy now if you want a paid plan with extended features. Next, you’ll be required to provide your Microsoft account details to sign up. If you don’t have one, you’ll have the option to create one:

单击“ Start Free按钮注册一个免费帐户,或者如果您想要具有扩展功能的付费计划,请buy now 。 接下来,将要求您提供Microsoft帐户详细信息以进行注册。 如果您没有,则可以选择创建一个:

Supply all your details and finish the signup process.

提供您的所有详细信息并完成注册过程。

Install Azure Functions extension Next up, let’s install the Azure Functions extension in VSCode. You can follow the or simply open Visual studio code, click on the Extensions icon on the left pane and type Azure in the extensions search bar:

安装Azure Functions扩展接下来,让我们在VSCode中安装Azure Functions扩展。 您可以遵循也可以打开Visual Studio代码,单击左窗格上的“扩展”图标,然后在扩展搜索栏中键入Azure:

Click install to install the extension. Once the installation is completed, you’ll see the Azure Functions logo appear at the Activity bar in VSCode:

单击install以安装扩展。 安装完成后,您将看到“ Azure Functions”徽标出现在VSCode的“活动”栏中:

We have successfully created an Azure account and installed the Azure Functions extension in VSCode. Now when you click the Azure Functions logo in the activity bar, it will open the Azure Functions explorer where you will be prompted to sign in with your Azure account or create a new one:

我们已经成功创建了一个Azure帐户,并在VSCode中安装了Azure Functions扩展。 现在,当您单击活动栏中的“ Azure Functions”徽标时,它将打开“ Azure Functions”浏览器,系统将提示您使用Azure帐户登录或创建一个新帐户:

Click Sign in to Azure, this will generate an access code for you in VSCode and prompt you to launch your default browser to the Azure authentication page where you’ll be required to supply the code:

单击“ Sign in to Azure ,这将在VSCode中为您生成访问代码,并提示您将默认浏览器启动到Azure身份验证页面,在该页面中将需要您提供代码:

Paste the access code generated from VSCode into the code bar here and wait for this success message:

将从VSCode生成的访问代码粘贴到此处的代码栏中,然后等待以下成功消息:

Once you get this, you have successfully signed in your Azure account to your VSCode. Go ahead and restart VSCode to apply the changes.

收到此证书后,便已成功将Azure帐户登录到VSCode。 继续并重新启动VSCode以应用更改。

Install Azure Functions Core Tools Next, we install the OS-specific Azure Functions core tools globally to enable local debugging.

安装Azure Functions核心工具接下来,我们在全局安装特定于操作系统的Azure Functions核心工具,以启用本地调试。

On macOS, install using :

在macOS上 ,使用安装:

$ brew tap azure/functions    $ brewinstall azure-functions-core-tools

On Windows, install using :

在Windows上 ,使用安装:

$npm install -g azure-functions-core-tools

On Linux, follow the instructions in the Azure Functions Core Tools .

在Linux上 ,按照Azure Functions Core Tools 。

Once installed, open a Terminal/Powershell and run the func command to ensure that the installation was successful:

安装完成后,打开终端/ Powershell并运行func命令以确保安装成功:

Awesome, we have everything set up appropriately. As a way of ensuring that all the prerequisites were installed and configured correctly, you should see your Azure email address in the Status Bar and your subscription in the Azure Functions explorer inside VSCode.

太好了,我们已经适当地设置了所有内容。 为了确保正确安装和配置了所有必备组件,您应该在VSCode中的状态栏中看到您的Azure电子邮件地址,并在Azure Functions资源管理器中看到您的订阅。

Create a new Function App Next, we create a new Function application using the Azure Functions extension. Click the Azure Functions logo in the Activity bar to open up the Azure Functions explorer. Then in the explorer, click the Create project icon:

创建一个新的Function应用程序接下来,我们使用Azure Functions扩展创建一个新的Function应用程序。 单击活动栏中的Azure Functions徽标以打开Azure Functions资源管理器。 然后在资源管理器中,单击创建项目图标:

Clicking the Create project icon will prompt you to select a folder to store your Function App. For the purpose of this tutorial, create an empty folder on the Desktop and select it.

单击创建项目图标将提示您选择一个文件夹来存储您的Function App。 就本教程而言,请在桌面上创建一个空文件夹并选择它。

Once you’ve chosen a project folder, you’ll be prompted to select a preferred language for your Function App

选择项目文件夹后,系统将提示您为Function App选择首选语言

For the scope of this project, select JavaScript and press Enter. This will create the project in the selected folder and prompt you to select a window to open the project.

对于此项目的范围,选择JavaScript并按Enter。 这将在选定的文件夹中创建项目,并提示您选择一个窗口以打开项目。

Open the app in the current window and create a new function with the Create function icon on the Azure Function explorer.

在当前窗口中打开应用程序,并使用Azure Function资源管理器上的Create function图标创建一个新功能。

You’ll be prompted to select a project folder to save the Function App. Select the directory you currently have open — it's the default option, so press Enter to proceed. Next, you’ll be required to select a Function template, you’ll have a wide range of options to choose from; however, we’ll concentrate on the HTTP Trigger template for now.

系统将提示您选择一个项目文件夹以保存Function App。 选择您当前打开的目录-这是默认选项,因此请按Enter继续。 接下来,将需要选择功能模板,您将有多种选择。 但是,我们现在将集中讨论HTTP触发器模板。

So select the HTTP Trigger template and press Enter to proceed. Then accept the default function name HTTPTriggerJS and select the anonymous authentication.

因此,选择HTTP触发器模板,然后按Enter继续。 然后接受默认的函数名称HTTPTriggerJS并选择匿名身份验证。

This is very much the last step in creating the Function App. When it is done, the project will be created and you’ll get the index.js file displayed:

这几乎是创建Function App的最后一步。 完成后,将创建该项目,并显示index.js文件:

Now our function app is created!! Let’s run it locally.

现在,我们的功能应用程序已创建! 让我们在本地运行它。

Run Function App To run the app, open the debugger in VSCode by clicking the debug icon in the Activity bar. It’ll open the debug explorer where you can click the green play button to start the app:

运行功能应用程序要运行该应用程序,请单击“活动”栏中的调试图标,以VSCode打开调试器。 它将打开调试浏览器,您可以在其中单击绿色的播放按钮以启动应用程序:

This will build the app and generate the local URL for your Function. Simply Ctrl + Click on it to open it up in the browser. You should be able to see the app in the browser like so:

这将构建应用程序并为您的功能生成本地URL。 只需Ctrl +单击它即可在浏览器中将其打开。 您应该能够在浏览器中看到该应用程序,如下所示:

The default HTTP template parses a name query parameter to customize the response, add ?name=<yourname> to the URL in your browser to see the response output correctly:

默认的HTTP模板解析name查询参数以自定义响应,将?name=<yourname>您的?name=<yourname>到浏览器中的URL以正确查看响应输出:

Now that we’ve got our App working and running locally, let’s deploy it to Azure Functions.

现在,我们的应用程序已在本地运行并运行,现在将其部署到Azure Functions。

Deploy to Azure Functions To deploy the App to Azure functions, open the Azure Functions explorer and click the Deploy to Function App arrow. This will prompt you to Select Function App. Press Create New Function App and press Enter to proceed.

部署到Azure功能要将应用程序部署到Azure功能,请打开Azure Functions资源管理器,然后单击“ 部署到功能应用程序”箭头。 这将提示您选择Function App 。 按Create New Function App ,然后按Enter继续。

Next, you will be required to select a unique name for the new Function App. Type a unique name of your choice and press Enter to proceed.

接下来,将要求您为新的Function App选择唯一的名称。 输入您选择的唯一名称,然后按Enter继续。

Next, you’ll be prompted to Select a resource group. At this point, you don’t have any, so click on Create new resource group.

接下来,系统将提示您选择一个资源组 。 此时,您还没有任何资源 ,因此请单击创建新资源组

Enter your preferred resource group name and proceed. Now you will be required to Select a storage account for your app. At this point, you won’t have any existing storage account, so click on Create new storage account.

输入您首选的资源组名称,然后继续。 现在,您将需要选择应用程序的存储帐户 。 此时,您将没有任何现有的存储帐户,因此请点击创建新的存储帐户

Now enter a name for the new storage account.

现在输入新存储帐户的名称。

Next, you will be required to select your location for new resources. Select a location in a near you or near other services you may need to access and press Enter to proceed.

接下来,将要求您选择新资源的位置。 在您附近或您可能需要访问的其他服务附近的选择一个位置,然后按Enter继续。

Once you’ve selected your nearest region, it’ll take a little while to set up your configurations and deploy your application. At the end of the process, you should get a success message like this:

选择最近的区域后,将需要一些时间来设置配置和部署应用程序。 在该过程的最后,您应该获得如下成功消息:

The process will provide a deployed URL for your application. Open the Output tab on the Terminal pane in VSCode to see the URL:

该过程将为您的应用程序提供一个已部署的URL。 在VSCode的“终端”窗格中打开“输出”选项卡,以查看URL:

Browse the website Now when you Ctrl+click on the URL, you’ll get your function app live on the browser

浏览网站现在,当您按住Ctrl键并单击URL时,将在浏览器中启用功能应用程序

Conclusion Congratulations!! You have now:

结论恭喜! 您现在有:

  • Installed Azure Functions Extension

    已安装的Azure功能扩展
  • Created an Azure Functions App and Function

    创建了Azure Functions应用和功能
  • Deployed your app successfully to Azure

    将您的应用成功部署到Azure

翻译自:

vs 部署 azure

转载地址:http://cruwd.baihongyu.com/

你可能感兴趣的文章
003.第一个动画:绘制直线
查看>>
K2BPM怎么让金融数据更有意义?
查看>>
史玉柱自述:我是如何带队伍的
查看>>
靶形数独【贪心+深搜】
查看>>
读大道至简第三章有感
查看>>
BeforeFieldInit的小叙
查看>>
TeamViewer的下载地址,低调低调
查看>>
005 线程ID和线程的优先级
查看>>
POJ 3067 Japan (树状数组 && 控制变量)
查看>>
python基础条件和循环
查看>>
an exciting trip
查看>>
【转】xmind8 破解激活教程
查看>>
Mysql用命令方式启动服务
查看>>
【贪心】codeforces A. Heidi and Library (easy)
查看>>
【leetcode】lower_bound
查看>>
跨站请求伪造(CSRF)
查看>>
EF Code First数据库映射规则及配置
查看>>
.Net StackFrame
查看>>
Qt 学习之路:视图选择 (QItemSelectionModel)
查看>>
QStyleFactory类参考
查看>>