Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

huangapple go评论68阅读模式
英文:

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

问题

I am using Jetbrains Rider on my Mac to develop some Azure Functions (.NET 6/C#). I use Azure Toolkit to deploy them to Azure (CI/CD processes would be over-engineered in this cases). The basic deployment works perfectly fine to me.

However, in Visual Studio Professional/Enterprise on my company's laptop (using Windows) I have the option to deploy Azure Functions with a selected sub-set of local settings.

For anybody who is interested in this option, it is described here (screenshots are not up-to-date with VS 2022, but you will find it): https://learn.microsoft.com/en-us/answers/questions/513945/how-can-i-make-azure-functions-use-settings-in-loc

Is there any build in option in Jetbrains Rider? Or do I have to use Azure CLI?

英文:

I am using Jetbrains Rider on my Mac to develop some Azure Functions (.NET 6/C#). I use Azure Toolkit to deploy them to Azure (CI/CD processes would be over-engineered in this cases). The basic deployment works perfectly fine to me.

However, in Visual Studio Professional/Enterprise on my company's laptop (using Windows) I have the option to deploy Azure Functions with a selected sub-set of local settings.

For anybody who is interested in this option, it is described here (screenshots are not up-to-date with VS 2022, but you will find it): https://learn.microsoft.com/en-us/answers/questions/513945/how-can-i-make-azure-functions-use-settings-in-loc

Is there any build in option in Jetbrains Rider? Or do I have to use Azure CLI?

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

答案1

得分: 2

Here is the translated content:

> 默认情况下,local.settings.json不会在Azure Functions中部署,因为它用于本地开发,并且它是gitignore文件的一部分,在运行时不包括在内,参考这个SO线程回答由Chris B和下面:

gitignore文件:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

在使用Jet-Brains Rider发布Azure Functions时,很不幸,没有选项来在发布时编辑和配置应用程序设置,就像我们在Visual Studio code中所做的那样,但您可以使用Azure工具包> Azure Explorer和Function应用程序进行添加,参考下面:

我在我的JetBrains IDE中创建了一个Azure Function应用程序,并像下面这样发布它:

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

在Function中添加了HTTP触发器,如下所示:

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

我在本地运行了Function,并且触发成功:

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

**在将此Function发布到Azure的function应用程序时,没有编辑应用程序设置的选项,**参考下面:

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

**我点击了“运行”,Function成功部署在function应用程序中,**参考下面:

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

在发布触发器之前或之后,您可以按照下面的步骤在Function应用程序中添加appsettings:

在JetBrains Rider中转到Azure Explorer>选择您的Function应用程序>右键单击>显示属性,如下所示:

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

Function应用程序发布配置文件和应用程序设置页面将加载>在应用程序设置右侧的“+”按钮上单击,然后添加您的设置,如下所示:

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

单击“保存”以保存您的应用程序设置,如下所示:

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

应用程序设置已成功添加到Function应用程序,请参考下面:

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

应用程序设置在门户中反映出来:

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

您是对的,作为解决方法,您可以通过Azure CLI直接添加Function应用程序设置,如下所示:

命令:

我从此MS文档引用了下面的命令。

az functionapp config appsettings set --name siliconfunc45 --resource-group siliconrg1 --settings 'SCM_DO_BUILD_DURING_CONFIGURATION = true'

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

门户:

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

英文:

> By default local.settings.json is not deployed in Azure Functions as it is used for local development and also its part of gitignore file where it is not included during runtime, Refer this SO thread answer by Chris B and below:-

gitignorefile:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

While Publishing Azure Functions with Jet-Brains Rider unfortunately, There's no option to Edit and configure App settings while Publishing as we have in Visual Studio code, But you can add it with Azure tool kit > Azure Explorer and Function app Refer below:-

I created one Azure Function app in my JetBrains IDE and Published it in my Azure Function app like below:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

Added HTTP Trigger in the Function like below:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

I ran the Function locally and it triggered successfully:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

While Publishing this Function to function app in Azure there's no option to edit app settings, Refer below:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

I clicked on Run and the Function was Deployed in function App successfully, Refer below:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

You can add the appsettings in your Function app before publishing your Trigger or after Publishing your Trigger as App settings is Function app level settings applied to all triggers inside it by following the steps below:-

Go to Azure Explorer in your JetBrains rider > Select your Function App > right click > Show Properties like below:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

Function app publish profile and app settings page will load > click on Add '+' Button on right section of app settings and add your settings like below:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

Click on Save like below to save your app settings:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

App settings added successfully in Function app refer below:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

App settings reflected in Portal:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

You're right, As a workaround you can directly add the Function App settings via Azure CLI like below:-

Command:-

I have referred the below command from this MS Document.

az functionapp config appsettings set --name siliconfunc45 --resource-group siliconrg1 --settings 'SCM_DO_BUILD_DURING_CONFIGURATION = true'

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

Portal:-

Deploying Azure Function with Jetbrains Rider and Azure Toolkit with local settings

huangapple
  • 本文由 发表于 2023年5月14日 00:32:34
  • 转载请务必保留本文链接:https://go.coder-hub.com/76243821.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定