Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/react-native/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在azuredeploy中使用选项和设置_Azure_Azure Devops_Azure Functions_Azure Deployment_.net Core 3.1 - Fatal编程技术网

如何在azuredeploy中使用选项和设置

如何在azuredeploy中使用选项和设置,azure,azure-devops,azure-functions,azure-deployment,.net-core-3.1,Azure,Azure Devops,Azure Functions,Azure Deployment,.net Core 3.1,遵循Azure Function v3和dotnet core 3.1中的DI文档可以完美地工作 但我正在搜索格式选项中的set参数:我在azuredeploy.json中的local.settgins.json中的设置 在VisualStudio中测试使用ARM项目部署时,我遇到了这个错误。 我还没有尝试,但我还需要在azuredevops管道变量中为不同的环境设置一个参数 非常感谢你的帮助 错误 local.settings.json { "IsEncrypted": false,

遵循
Azure Function v3
dotnet core 3.1
中的DI文档可以完美地工作

但我正在搜索格式选项中的set参数:我在azuredeploy.json中的local.settgins.json中的设置

在VisualStudio中测试使用ARM项目部署时,我遇到了这个错误。 我还没有尝试,但我还需要在
azuredevops
管道变量中为不同的环境设置一个参数

非常感谢你的帮助

错误

local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "option:setting": "value"
  }
}
{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    ...
    "option": {
      "value": {
        "setting": "value"
      }
    }
  }
}
"resources": [
{
  "apiVersion": "2017-05-10",
  "name": "functionApp",
  "type": "Microsoft.Resources/deployments",
  "properties": {
    "parameters": {
      ...
      "additionalAppSettings": {
        "value": {
          "MSDEPLOY_RENAME_LOCKED_FILES": "1",
          "option:setting": "[parameters('option').setting]"
        }
      }
    },
    "debugSetting": {
      "detailLevel": "requestContent,responseContent"
    }
  }
},
{
  "IsEncrypted": false,
  "Values": {
    "option__setting": "value"
  }
}
"resources": [
{
  "apiVersion": "2017-05-10",
  "name": "functionApp",
  "type": "Microsoft.Resources/deployments",
  "properties": {
    "parameters": {
      ...
      "additionalAppSettings": {
        "value": {
          "MSDEPLOY_RENAME_LOCKED_FILES": "1",
          "option__setting": "[parameters('option').setting]"
        }
      }
    },
    "debugSetting": {
      "detailLevel": "requestContent,responseContent"
    }
  }
},
Startup.cs

[assembly: FunctionsStartup(typeof(MyProject.Startup))]
namespace MyProject
{
    public class Startup : FunctionsStartup
    {
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddOptions<MyOption>()
                .Configure<IConfiguration>((settings, configuration) => configuration.GetSection("option").Bind(settings));
        }
    }
}
azuredeploy.json

{
  "IsEncrypted": false,
  "Values": {
    "option:setting": "value"
  }
}
{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    ...
    "option": {
      "value": {
        "setting": "value"
      }
    }
  }
}
"resources": [
{
  "apiVersion": "2017-05-10",
  "name": "functionApp",
  "type": "Microsoft.Resources/deployments",
  "properties": {
    "parameters": {
      ...
      "additionalAppSettings": {
        "value": {
          "MSDEPLOY_RENAME_LOCKED_FILES": "1",
          "option:setting": "[parameters('option').setting]"
        }
      }
    },
    "debugSetting": {
      "detailLevel": "requestContent,responseContent"
    }
  }
},
{
  "IsEncrypted": false,
  "Values": {
    "option__setting": "value"
  }
}
"resources": [
{
  "apiVersion": "2017-05-10",
  "name": "functionApp",
  "type": "Microsoft.Resources/deployments",
  "properties": {
    "parameters": {
      ...
      "additionalAppSettings": {
        "value": {
          "MSDEPLOY_RENAME_LOCKED_FILES": "1",
          "option__setting": "[parameters('option').setting]"
        }
      }
    },
    "debugSetting": {
      "detailLevel": "requestContent,responseContent"
    }
  }
},

在文档中找到它

只需编辑local.settings.json并将char:替换为_u(有2个char

GetSection方法可以很好地使用它

现在对azuredeploy.json执行同样的操作

瞧,部署工作得很好,而且Cerise sur le gateau也可以在Linux上工作

local.settings.json

{
  "IsEncrypted": false,
  "Values": {
    "option:setting": "value"
  }
}
{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    ...
    "option": {
      "value": {
        "setting": "value"
      }
    }
  }
}
"resources": [
{
  "apiVersion": "2017-05-10",
  "name": "functionApp",
  "type": "Microsoft.Resources/deployments",
  "properties": {
    "parameters": {
      ...
      "additionalAppSettings": {
        "value": {
          "MSDEPLOY_RENAME_LOCKED_FILES": "1",
          "option:setting": "[parameters('option').setting]"
        }
      }
    },
    "debugSetting": {
      "detailLevel": "requestContent,responseContent"
    }
  }
},
{
  "IsEncrypted": false,
  "Values": {
    "option__setting": "value"
  }
}
"resources": [
{
  "apiVersion": "2017-05-10",
  "name": "functionApp",
  "type": "Microsoft.Resources/deployments",
  "properties": {
    "parameters": {
      ...
      "additionalAppSettings": {
        "value": {
          "MSDEPLOY_RENAME_LOCKED_FILES": "1",
          "option__setting": "[parameters('option').setting]"
        }
      }
    },
    "debugSetting": {
      "detailLevel": "requestContent,responseContent"
    }
  }
},
azuredeploy.json

{
  "IsEncrypted": false,
  "Values": {
    "option:setting": "value"
  }
}
{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    ...
    "option": {
      "value": {
        "setting": "value"
      }
    }
  }
}
"resources": [
{
  "apiVersion": "2017-05-10",
  "name": "functionApp",
  "type": "Microsoft.Resources/deployments",
  "properties": {
    "parameters": {
      ...
      "additionalAppSettings": {
        "value": {
          "MSDEPLOY_RENAME_LOCKED_FILES": "1",
          "option:setting": "[parameters('option').setting]"
        }
      }
    },
    "debugSetting": {
      "detailLevel": "requestContent,responseContent"
    }
  }
},
{
  "IsEncrypted": false,
  "Values": {
    "option__setting": "value"
  }
}
"resources": [
{
  "apiVersion": "2017-05-10",
  "name": "functionApp",
  "type": "Microsoft.Resources/deployments",
  "properties": {
    "parameters": {
      ...
      "additionalAppSettings": {
        "value": {
          "MSDEPLOY_RENAME_LOCKED_FILES": "1",
          "option__setting": "[parameters('option').setting]"
        }
      }
    },
    "debugSetting": {
      "detailLevel": "requestContent,responseContent"
    }
  }
},

“使用Visual Studio测试部署”是什么意思?您是说在VisualStudio中使用Web部署机制进行发布吗?发布之前,我从VisualStudio上的ARM项目进行部署。这是出现错误的地方。我认为startup.cs中的configuration.GetSection(“option”)应该是值(请参阅local.settings.json)。感谢您在这里分享您的解决方案,这可以让其他与您有相同难题的人受益。你可以,这样其他人就可以直接知道这是工作。