1.1 前提
- Azure 账户并有可食用的订阅。创建免费的 Azure 账户。
- Azure 支持的 Java Development Kit (JDK),JDK 8 或 JDK 11。
- IntelliJ IDEA 无限制版本或社区版本均可。
- Maven 3.5+
- 最新的 Function Core Tools
1.2 安装插件并登录
在 IntelliJ IDEA 中安装 Azure Toolkit 插件并登录,具体步骤如下:
-
在 IntelliJ IDEA
Settings/Perfernced
中选择Plug
。在MarketPlace
中找到Azure Toolkit for IntelliJ
,并点击install
。在安装完成后点击Restart
插件可被使用。 -
要登录 Azure account,首先打开侧边栏中的
Azure Explore
,然后点击菜单顶部 (或者在 IDEA 菜单中,选择Tools > Azure > Azure Sign In
)Azure Sign In
图标。 -
在
Azure Sign In
窗口选择OAuth 2.0
然后点击Sign In
。如果使用其他登录选项,请参考 Sign-in instructions for the Azure Toolkit for IntelliJ。 -
在浏览器中登录 Azure account,然后返回到 IntelliJ。在
Select Subscription
对话框中选择您想要使用的订阅,并点击Select
。1.3 创建本地项目
使用 Azure Toolkit 通过 IntelliJ 创建本地的 Azure Function 项目,具体步骤如下:
-
打开 IntelliJ IDEA 您会看到
Welcome
对话框,选择New Project
打开新项目创建指导,并选择Azure Functions
。 -
选择
Http Trigger
,然后点击Next
随后根据创建指引完善在后续页面中的配置信息。确认您项目的地址,随后点击Finish
。IntelliJ IDEA 将会创建并在窗口中打开您的项目。
-
1.3 在本地运行项目
在本地运行项目,跟随以下步骤:
:warning: Important
You must have the JAVA_HOME environment variable set correctly to the JDK directory that is used during code compiling using Maven. Make sure that the version of the JDK is at least as high as the
Java.version
setting.
-
导航到 src/main/java/org/example/functions/HttpTriggerFunction.java 来查看生成的代码。在第 24 行旁边,你会发现有一个绿色的
Run
按钮。点击它并选择运行Run 'Functions-azur...'
。你会看到你的函数应用正在本地运行,并有一些日志。
-
你可以通过从浏览器访问显示的端点来尝试该功能,如
http://localhost:7071/api/HttpExample?name=Azure
。 -
该日志也会显示在你的IDEA中。点击
Stop
按钮,停止该功能应用。
1.4 在本地 Debug 项目
在本地 Debug 项目,具体步骤如下:
-
选择 Debug 按钮在工具栏中,如果您未找到工具栏,请通过在菜单中选择
View > Apperance > Toolbar
以激活菜单栏。 -
点击文件 src/main/java/org/example/functions/HttpTriggerFunction.java 的第 31 行,添加一个断点。再次访问端点
http://localhost:7071/api/HttpTrigger-Java?name=Azure
,你会发现断点被击中。然后,你可以尝试更多的调试功能,如Step、Watch、and Evaluation
。点击Stop
按钮,停止调试会话。
1.5 部署您的项目到 Azure 上
部署您的 Azure Function App 到 Azure 上具体步骤如下:
-
右键点击 IntelliJ 项目资源管理器中的你的项目。然后选择
Azure > Deploy > to Azure Functions
。
- IntelliJ Function Azure IDEA Javaintellij function azure idea intellij项目idea java intellij项目java idea function functions-container-action azure developer azure microsoft function runtime azure parameterbindingdata microsoft function azure函数function页面 azure microsoft function版本 function内存 错误azure function azure错误app