小编Rak*_*mar的帖子

Azure Functions - 拥有 host.json 和 local.settings.json 的目的是什么

我可以看到 Azure Function 目录中添加了两个 json 文件(host.json 和 local.settings.json)。

主机文件

{
    "version": "2.0",
    "logging": {
        "applicationInsights": {
            "samplingExcludedTypes": "Request",
            "samplingSettings": {
                "isEnabled": true
            }
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

本地设置.json

{
  "IsEncrypted": false,
  "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet"
  }
}
Run Code Online (Sandbox Code Playgroud)

拥有这两个json文件的目的是什么?

azure azure-functions

10
推荐指数
2
解决办法
8637
查看次数

IdentityServer4的AddSigningCredential

我们将IdentityServer4与.NET Core Web应用程序一起使用(“ http://docs.identityserver.io/en/release/quickstarts/0_overview.html ”)。我们已替换AddDeveloperSigningCredentialAddSigningCredential(CreateSigningCredential())。由于我们不能AddDeveloperSigningCredential用于生产环境,因为生产中需要用一些持久的密钥材料代替。我们是IdentityServer4的新手,我们的问题是,以下方法可以在生产环境中创建签名凭证吗?还是我们需要对此进行一些更改?

这是我们的startup.cs文件:

public void ConfigureServices(IServiceCollection services)
{
    services.AddSingleton<IConfiguration>(Configuration);

    //connection string
    string connectionString = Configuration.GetConnectionString("IdentityServer");

    var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;

    services.AddIdentityServer().AddDeveloperSigningCredential
    .AddSigningCredential(CreateSigningCredential())
    // this adds the config data from DB (clients, resources)
    .AddConfigurationStore(options =>
    {
        options.ConfigureDbContext = builder =>
        builder.UseSqlServer(connectionString,
            sql => sql.MigrationsAssembly(migrationsAssembly));
                }) // this adds the operational data from DB (codes, tokens, consents)
    .AddOperationalStore(options =>
    {
        options.ConfigureDbContext = builder =>
        builder.UseSqlServer(connectionString,
            sql => sql.MigrationsAssembly(migrationsAssembly));

        // this enables automatic token cleanup. …
Run Code Online (Sandbox Code Playgroud)

identityserver4

9
推荐指数
3
解决办法
1万
查看次数

要访问 VisualStudio.com 帐户,请使用上面的选择器登录

当我尝试添加 TFS 服务器时,我收到了警告消息“要访问 VisualStudio.com 帐户,请使用上面的选择器登录”,如以下屏幕截图所示。谁能建议我如何解决这个问题?

在此输入图像描述

visual-studio azure-devops

8
推荐指数
3
解决办法
1万
查看次数

.NET Core 3.1 SOAP 平台不支持错误“不支持编译 JScript/CSharp 脚本”

我正在使用 Amadeus 提供的 WSDL 文件 (wsdl.zip)。当尝试使用下面的代码调用服务方法时,它抛出了一个 System.PlatformNotSupportedException 说“ Compiling JScript/CSharp scripts is not supported

public async Task<Fare_MasterPricerTravelBoardSearchResponse> SearchFlight(Session session,
            Fare_MasterPricerTravelBoardSearch searchData)
        {
            var _client = new AmadeusWebServicesPTClient();
            var result = await _client.Fare_MasterPricerTravelBoardSearchAsync(session, searchData);
            return result;
        }
Run Code Online (Sandbox Code Playgroud)

这真的是工具还不支持的东西吗?

堆栈跟踪:

at System.Xml.Serialization.TempAssembly..ctor(XmlMapping[] xmlMappings, Type[] types, String defaultNamespace, String location)
   at System.Xml.Serialization.XmlSerializer.GetSerializersFromCache(XmlMapping[] mappings, Type type)
   at System.Xml.Serialization.XmlSerializer.FromMappings(XmlMapping[] mappings, Type type)
   at System.ServiceModel.Description.XmlSerializerHelper.FromMappingsViaReflection(XmlMapping[] mappings, Type type)
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GenerateSerializers()
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerGenerationContext.GetSerializer(Int32 handle)
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.SerializerStub.GetSerializer()
   at System.ServiceModel.Description.XmlSerializerOperationBehavior.Reflector.MessageInfo.get_HeaderSerializer()
   at System.ServiceModel.Dispatcher.XmlSerializerOperationFormatter.AddHeadersToMessage(Message message, MessageDescription messageDescription, Object[] parameters, Boolean …
Run Code Online (Sandbox Code Playgroud)

c# wcf soap .net-core

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

我们如何获取 Azure Function App 的租户 ID、客户端 ID 和客户端密钥?

我将使用 Azure Function App 的密钥保管库。

我正在使用.NET SDK。

  1. Azure.Security.KeyVault.Secrets
  2. Azure.身份

例子:

string keyVaultUrl = configuration["KeyVaultSettings:Url"];

            TokenCredential credential = new DefaultAzureCredential();
#if DEBUG
            credential = new ClientSecretCredential(configuration["AZURE_TENANT_ID"],
                                                    configuration["AZURE_CLIENT_ID"],
                                                    configuration["AZURE_CLIENT_SECRET"]);
#endif

            var secretClient = new SecretClient(new Uri(keyVaultUrl), credential);
Run Code Online (Sandbox Code Playgroud)

要在本地调试我需要

tenant_id、client_id 和 client_secret。

我怎样才能得到这个?

azure azure-keyvault azure-functions

7
推荐指数
1
解决办法
3万
查看次数

Azure Function:IWebJobsStartup 和 FunctionsStartup 之间的区别

我正在使用 Azure Function(v3),我可以在startup.cs 中使用 IWebJobsStartup 和 FunctionsStartup 注册依赖项。

但我们应该使用哪一个呢?

使用 IWebJobsStartup 注册依赖项

[assembly: WebJobsStartup(typeof(Startup))]
namespace Notifications.Receiver
{
    public class Startup : IWebJobsStartup
    {
        public void Configure(IWebJobsBuilder builder)
        {
            builder.Services.AddTransient<IEventValidator, EventValidator>();
            builder.Services.AddTransient<IEventReceiverHandler, EventReceiverHandler>();

            builder.Services.AddTransient<IEventHandler<InvoiceResultDto,InvoiceMessageEvent>, InvoiceMessageEventHandler>();
            builder.Services.AddTransient<IEventHandler<InvoiceResultDto, InvoiceFileEvent>, InvoiceFileEventHandler>();
            builder.Services.AddSingleton<IMessageBusFactory, AzureServiceBusFactory>();

            builder.Services.Configure<KestrelServerOptions>(options =>
            {
                options.AllowSynchronousIO = true;
            });
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

我也可以使用 FunctionsStartup 注册相同的依赖项

[assembly: FunctionsStartup(typeof(Startup))]
namespace Notifications.Receiver
{
    public class Startup : FunctionsStartup
    {
        public override void Configure(IFunctionsHostBuilder builder)
        {
            builder.Services.AddTransient<IEventValidator, EventValidator>();
            builder.Services.AddTransient<IEventReceiverHandler, EventReceiverHandler>();

            builder.Services.AddTransient<IEventHandler<InvoiceResultDto,InvoiceMessageEvent>, InvoiceMessageEventHandler>();
            builder.Services.AddTransient<IEventHandler<InvoiceResultDto, InvoiceFileEvent>, InvoiceFileEventHandler>();
            builder.Services.AddSingleton<IMessageBusFactory, AzureServiceBusFactory>(); …
Run Code Online (Sandbox Code Playgroud)

c# dependency-injection azure-functions

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

我们可以设置访问令牌不过期吗?

我们使用的是 Identity Server4,默认时间是访问令牌过期时间是 3600 秒。我们可以设置它不过期吗?

public static IEnumerable<Client> GetClients()
    {
        return new List<Client>
         {
         new Client
        {
        ClientId = "client",

        // no interactive user, use the clientid/secret for authentication
            AllowedGrantTypes = GrantTypes.ClientCredentials,

        // secret for authentication
            ClientSecrets =
            {
            new Secret("secret".Sha256())
            },

        // scopes that client has access to
            AllowedScopes = { "api1" },
            AccessTokenLifetime=3600
    }
};
Run Code Online (Sandbox Code Playgroud)

c# .net-core identityserver4

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

Azure 数据工厂(ADF)与 Azure Functions:如何选择?

目前我们正在使用 Blob 触发器 Azure Functions 将 json 数据移动到 Cosmos DB。我们计划用 Azure 数据工厂 (ADF) 管道替换 Azure Functions。我是 Azure 数据工厂(ADF)的新手,所以不确定,Azure 数据工厂(ADF)管道是否是更好的选择?

azure azure-functions

5
推荐指数
2
解决办法
2515
查看次数

log4net:错误使用 null 'element' 参数调用ConfigureFromXml

我们使用 log4net 库和 .NET Core 将日志写入文件。但是,在执行应用程序“log4net:错误的ConfigureFromXml 使用 null 'element' 参数调用”时,我们收到此错误。这是我们的 Program.cs 文件:

public class Program
{
    public static void Main(string[] args)
    {
        XmlDocument log4netConfig = new XmlDocument();
        log4netConfig.Load(File.OpenRead("log4net.config"));
        var repo = log4net.LogManager.CreateRepository(Assembly.GetEntryAssembly(), typeof(log4net.Repository.Hierarchy.Hierarchy));
        log4net.Config.XmlConfigurator.Configure(repo, log4netConfig["log4net"]);

        BuildWebHost(args).Run();
    }

    public static IWebHost BuildWebHost(string[] args) =>
        WebHost.CreateDefaultBuilder(args)
            .UseStartup<Startup>()
            .Build();
}
Run Code Online (Sandbox Code Playgroud)

这是Startup.cs文件中的Configure方法:

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        loggerFactory.AddConsole(LogLevel.Trace);
        loggerFactory.AddLog4Net();

        app.UseIdentityServer();
    }
Run Code Online (Sandbox Code Playgroud)

这是 log4net.config 文件:

    <?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=1.2.10.0, Culture=neutral, …
Run Code Online (Sandbox Code Playgroud)

log4net asp.net-core

4
推荐指数
2
解决办法
4335
查看次数

Azure Cosmos DB -“请求率很大。” 删除项目时可能需要更多请求单位”错误

我正在使用下面的存储过程从 cosmos db 集合中删除项目。

function bulkDeleteStoredProcedure(query) {
    var collection = getContext().getCollection();
    var collectionLink = collection.getSelfLink();
    var response = getContext().getResponse();
    var responseBody = {
        deleted: 0,
        continuation: true
    };

    // Validate input.
    if (!query) throw new Error("The query is undefined or null.");

    tryQueryAndDelete();

    // Recursively runs the query w/ support for continuation tokens.
    // Calls tryDelete(documents) as soon as the query returns documents.
    function tryQueryAndDelete(continuation) {
        var requestOptions = {continuation: continuation};

        var isAccepted = collection.queryDocuments(collectionLink, query, requestOptions, function (err, retrievedDocs, responseOptions) …
Run Code Online (Sandbox Code Playgroud)

azure azure-cosmosdb azure-cosmosdb-sqlapi

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