Azure App Services在配置中添加字符串数组 [英] Azure App Services Add array of strings in configuration

查看:72
本文介绍了Azure App Services在配置中添加字符串数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Net核心应用程序,并将该应用程序部署在Azure App Services中.在我的应用程序中,我有一个应用程序settings.json文件,其中包含以下内容

Net core application and deploying the application in Azure App Services. In my application, I have an app settings.json file with below content

"Roles": {
    "Roles": [
        "Admins",
        "Users"
    ]
}

我的ARM模板中具有以下配置.

I have the below configuration in my ARM template.

Parameters.json

Parameters.json

"Roles": {
    "value": [
        "Admins",
        "Users"
    ]
}

我正尝试在以下应用设置中添加值

I am trying to add values in app settings as below

{
    "name": "Roles__Roles",
    "value": "[parameters('Roles')]" 
}

这给了我一个例外

2021-01-19T10:25:17.0538350Z ## [错误]详细信息:
2021-01-19T10:25:17.0539754Z ## [错误]未定义:HTTP请求正文不能为空.

2021-01-19T10:25:17.0538350Z ##[error]Details:
2021-01-19T10:25:17.0539754Z ##[error]undefined: HTTP request body must not be empty.

有人可以帮我解决这个问题吗?

Can someone help me to fix this?

推荐答案

据我了解,为应用服务"提供的应用设置值必须为字符串类型.但是,您的参数"Roles"是数组类型.因此,需要转换为字符串.试试这个:

As far as I understand, the app settings values provided for the App Service need to be of type string. However, your parameter "Roles" is of type array. Thus, a conversion to string is required. Try this:

{
    "name": "Roles__Roles",
    "value": "[string(parameters('Roles'))]"
}

对象类型的参数也是如此.

The same applies to parameters of type object.

不幸的是,错误消息对澄清这一点完全没有帮助.

Unfortunately, the error message is not at all helpful in clarifying this.

参考文献:

这篇关于Azure App Services在配置中添加字符串数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆