小编Amo*_*mor的帖子

如何在.NET Core中进行应用程序设置转换为Azure应用程序设置?

我不记得我在哪里看到这个,但在为我的.NET Core MVC应用程序设置应用程序配置时,我在博客上遵循了建议.我创建了这样的模型来保存我的应用程序所需的一些设置:

public class BasePathSettings
{
    public string BaseImageFolder { get; set; }
    public string BaseApiUrl { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

我的StartUp有这个......

    public void ConfigureServices(IServiceCollection services)
    {
        ... 
        // this adds the base paths to container
        services.Configure<BasePathSettings>(Configuration.GetSection("BasePathSettings"));

        ....
    }
Run Code Online (Sandbox Code Playgroud)

而appsettings.json中有这个:

"BasePathSettings": {
  "BaseImageFolder": "D:\\Images\\",
  "BaseApiUrl": "http://localhost:50321/"
},
Run Code Online (Sandbox Code Playgroud)

我注入了需要这些信息的控制器......

    private readonly BasePathSettings _settings;

    public ClientsController(IOptions<BasePathSettings> settings)
    {
        _settings = settings.Value;

        _client = new HttpClient();
        _client.BaseAddress = new Uri(_settings.BaseApiUrl);
    }
Run Code Online (Sandbox Code Playgroud)

在我的localhost上运行它一切正常.

但是,当我将此应用程序部署到Azure时,我假设我需要在应用程序服务的常规设置中创建应用程序设置.所以我创建了一个名为BasePathSettings的应用程序设置,并将设置的json复制到值中:

 { "BaseImageFolder": "imagePath", "BaseApiUrl": "apiUrl" } 
Run Code Online (Sandbox Code Playgroud)

似乎Azure barfs在ConfigureServices代码中声称web.config在NTFS中没有正确的权限.我猜测真正的罪魁祸首是如何从Azure应用程序设置中读取json值.

我甚至可以在那里使用json吗?如果是这样,它需要格式不同吗?

azure application-settings azure-web-sites asp.net-core-mvc

4
推荐指数
1
解决办法
1504
查看次数

限制 Azure 应用服务中的并发请求

鉴于以下

  • ASP.NET Web API 应用程序
  • 目标:.NET Framework 4.6.1
  • 作为 Azure 应用服务托管

我希望限制对应用程序的并发 HTTP 请求总数。

我看过https://github.com/stefanprodan/WebApiThrottle但这似乎集中在不同的用例上。

我想在 IIS 中等效于此设置:https : //forums.asp.net/t/1683143.aspx?Max+concurrent+requests

azure asp.net-web-api azure-web-app-service

2
推荐指数
1
解决办法
3681
查看次数

如何通过Api为Azure Sql数据库设置DTU?

我可以通过提及定价层来创建 Azure Sql 数据库。

我正在尝试设置数据库的内存和 DTU。

我无法找到正确的 Api,这是我尝试过的

PUT :    https://management.azure.com/subscriptions/<subscription-ID>/resourceGroups/<Resource-group-Name>/providers/Microsoft.Sql/servers/<Server-name>/databases/<Database-name>/?api-version=2014-04-01
Run Code Online (Sandbox Code Playgroud)

请求正文:

 {
                "location": "East Asia",
                "properties": {
                    "edition": "Premium",
                    "collation":"SQL_Latin1_General_CP1_CI_AS",
                "sampleName": "blank database",
                "serviceTierAdvisors":[
                    {
                        "maxSizeInGB":"150",
                        "maxDtu":"500"
                    }   
                    ]
                }   
    }
Run Code Online (Sandbox Code Playgroud)

我也没有收到正确的错误消息,任何人都可以指导我在数据库级别设置 DTU 的参数吗?

rest azure-resource-manager azure-sql-database azure-database-mysql

1
推荐指数
1
解决办法
4619
查看次数