英文:
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?
答案1
得分: 2
Here is the translated content:
> 默认情况下,local.settings.json不会在Azure Functions中部署,因为它用于本地开发,并且它是gitignore文件的一部分,在运行时不包括在内,参考这个SO线程回答由Chris B和下面:
gitignore文件:-
在使用Jet-Brains Rider发布Azure Functions时,很不幸,没有选项来在发布时编辑和配置应用程序设置,就像我们在Visual Studio code中所做的那样,但您可以使用Azure工具包> Azure Explorer和Function应用程序进行添加,参考下面:
我在我的JetBrains IDE中创建了一个Azure Function应用程序,并像下面这样发布它:
在Function中添加了HTTP触发器,如下所示:
我在本地运行了Function,并且触发成功:
**在将此Function发布到Azure的function应用程序时,没有编辑应用程序设置的选项,**参考下面:
**我点击了“运行”,Function成功部署在function应用程序中,**参考下面:
在发布触发器之前或之后,您可以按照下面的步骤在Function应用程序中添加appsettings:
在JetBrains Rider中转到Azure Explorer>选择您的Function应用程序>右键单击>显示属性,如下所示:
Function应用程序发布配置文件和应用程序设置页面将加载>在应用程序设置右侧的“+”按钮上单击,然后添加您的设置,如下所示:
单击“保存”以保存您的应用程序设置,如下所示:
应用程序设置已成功添加到Function应用程序,请参考下面:
应用程序设置在门户中反映出来:
您是对的,作为解决方法,您可以通过Azure CLI直接添加Function应用程序设置,如下所示:
命令:
我从此MS文档引用了下面的命令。
az functionapp config appsettings set --name siliconfunc45 --resource-group siliconrg1 --settings 'SCM_DO_BUILD_DURING_CONFIGURATION = true'
门户:
英文:
> 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:-
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:-
Added HTTP Trigger in the Function like below:-
I ran the Function locally and it triggered successfully:-
While Publishing this Function to function app in Azure there's no option to edit app settings, Refer below:-
I clicked on Run and the Function was Deployed in function App successfully, Refer below:-
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:-
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:-
Click on Save like below to save your app settings:-
App settings added successfully in Function app refer below:-
App settings reflected in Portal:-
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'
Portal:-
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论