当我使用 TimeTrigger 运行我的 azure 函数时,出现以下错误: Microsoft.Azure.WebJobs.Extensions.Timers.Storage:无法为 ScheduleMonitor 创建 BlobContainerClient。
我使用主机构建器:
public static async Task Main()
{
var host = CreateHostBuilder().Build();
using (host)
{
await host.RunAsync();
}
static IHostBuilder CreateHostBuilder() => new HostBuilder()
.UseServiceProviderFactory(new AutofacServiceProviderFactory())
.ConfigureFunctionsWorkerDefaults()
.ConfigureHostConfiguration(configHost =>
{
configHost.SetBasePath(Directory.GetCurrentDirectory());
configHost.AddJsonFile("host.json", optional: true);
configHost.AddEnvironmentVariables();
})
.ConfigureAppConfiguration((hostContext, configApp) =>
{
var env = hostContext.HostingEnvironment;
configApp.AddJsonFile("appsettings.json", optional: true);
configApp.AddJsonFile($"appsettings.{env.EnvironmentName}.json", optional: true);
configApp.AddEnvironmentVariables();
configApp.AddApplicationInsightsSettings(developerMode: !env.IsProduction());
})
.ConfigureServices((hostContext, services) =>
{
[...]
})
.ConfigureContainer<ContainerBuilder>(builder =>
{
builder.RegisterModule<MessagerModule>();
})
.ConfigureLogging((hostContext, configLogging) =>
{
if (hostContext.HostingEnvironment.IsDevelopment())
{ …Run Code Online (Sandbox Code Playgroud) 我想将Angular Web App中的音频流录制到我的Asp.net Core Api.
我认为,使用SignalR及其websockets这是一个很好的方法.
使用此打字稿代码,我可以获得MediaStream:
import { HubConnection } from '@aspnet/signalr';
[...]
private stream: MediaStream;
private connection: webkitRTCPeerConnection;
@ViewChild('video') video;
[...]
navigator.mediaDevices.getUserMedia({ audio: true })
.then(stream => {
console.trace('Received local stream');
this.video.srcObject = stream;
this.stream = stream;
var _hubConnection = new HubConnection('[MY_API_URL]/webrtc');
this._hubConnection.send("SendStream", stream);
})
.catch(function (e) {
console.error('getUserMedia() error: ' + e.message);
});
Run Code Online (Sandbox Code Playgroud)
我用.NetCore API处理流
public class MyHub: Hub{
public void SendStream(object o)
{
}
}
Run Code Online (Sandbox Code Playgroud)
但是当我将o转换为System.IO.Stream时,我得到了一个null.
当我阅读WebRTC的文档时,我看到了有关RTCPeerConnection的信息.IceConnection ......我需要吗?
如何使用SignalR将音频从WebClient流式传输到Asp.netCore API?文档?GitHub的?
谢谢你的帮助
我按照微软的文档进行集成测试: https://learn.microsoft.com/en-us/aspnet/core/test/integration-tests ?view=aspnetcore-6.0#introduction-to-integration-tests
在.net core 6中,startup.cs已被删除,我之前使用的集成测试不再按原样工作。我需要进行更新。
在我的 API csproj 中,我添加了:
<ItemGroup>
<InternalsVisibleTo Include="Integration.Tests" />
</ItemGroup>
Run Code Online (Sandbox Code Playgroud)
这是 Integration.Tests csproj:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Hosting.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="6.0.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.0.0" />
<PackageReference Include="xunit" Version="2.4.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.4.3">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" Version="3.1.0">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
</Project>
Run Code Online (Sandbox Code Playgroud)
我创建了一个 TestWebAppFactory.cs,如下所示:
public class TestWebAppFactory<TEntryPoint> : …Run Code Online (Sandbox Code Playgroud) 随着.Net 2.0引入了真正有用的ConsoleBuilder HostBuilder,就像我们使用WebHostBuilder for Web Application一样.
我现在关注的是如何使用带有QueueTrigger的WebJob实现HostBuilder?
到现在为止,我正在使用JobActivator:
var startup = new Startup();
var serviceProvider = startup.ConfigureServices(new ServiceCollection());
startup.Configure(serviceProvider);
var jobHostConfiguration = new JobHostConfiguration()
{
JobActivator = new JobActivator(serviceProvider),
};
var host = new JobHost(jobHostConfiguration);
host.RunAndBlock();
Run Code Online (Sandbox Code Playgroud)
有关完整示例,请参阅以下代码:https: //github.com/ranouf/DotNetCore-CosmosDbTrigger-WebJob/tree/master/CosmosDbTriggerWebJob.App
是否有人已经将HostBuilder用于带有QueueTrigger的WebJob?可能吗?
谢谢
您是否注意到Azure升级了AppSettings Management?现在可以使用高级编辑选项一次性更新多个 AppSettings,但格式与 AppSettings.json 不同。
我正在寻找一种快速解决方案,将我的 AppSettings 部分转换为 Azure 高级编辑选项格式。你知道怎么做吗?
所以这:
"Simulation": {
"ApiUrl": "YourApiUrl",
"ApiKey": "YouApiKey",
"Groups": [
{
"Name": "YourGroup",
"Latitude": 45.50884,
"Longitude": -73.58781,
"Radius": 500
}
],
"Planifications": [
{
"GroupName": "YourGroup",
"At": "07:00",
"Status": 10
}
]
}
Run Code Online (Sandbox Code Playgroud)
将被格式化为:
[
{
"Name": "Simulation:ApiUrl",
"Value": "YourApiUrl",
"SlotSetting": false
},
{
"Name": "Simulation:ApiKey",
"Value": "YourApiKey",
"SlotSetting": false
},
{
"Name": "Simulation:Groups:0:Name",
"Value": "YourGroup",
"SlotSetting": false
},
{
"Name": "Simulation:Groups:0:Latitude",
"Value": "45.50884",
"SlotSetting": false
},
{
"Name": "Simulation:Groups:0:Longitude",
"Value": …Run Code Online (Sandbox Code Playgroud) 自 11 月 22 日星期五以来,我在 Web 应用程序上部署更新时遇到了问题。仅更新了代码,几个月以来发布定义都是相同的。
这是日志:
2019-11-22T21:33:50.1660947Z ##[section]开始:XXXX API 部署 2019-11-22T21:33:50.1779651Z ==================== =================================================== ======== 2019-11-22T21:33:50.1779752Z 任务:Azure 应用服务部署 2019-11-22T21:33:50.1779839Z 描述:使用以下命令将 Web、移动或 API 应用部署到 Azure 应用服务Docker、Java、.NET、.NET Core、Node.js、PHP、Python 或 Ruby 2019-11-22T21:33:50.1779907Z 版本
:4.157.4 2019-11-22T21:33:50.1779976Z 作者:Microsoft Corporation 2019-11-22T21:33:50.1780041Z 帮助: https://learn.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-deployment 2019-11-22T21:33:50.1780145 Z =================================================== ============================= 2019-11-22T21:33:50.8476296Z 获取了 Azure 应用服务的服务连接详细信息:'XXXX -webapp-test' 2019-11-22T21:33:56.3772449Z 更新应用服务应用程序设置。数据:{"WEBSITE_RUN_FROM_PACKAGE":"1"} 2019-11-22T21:33:56.8621554Z 更新了应用服务应用程序设置和 Kudu 应用程序设置。2019-11-22T21:34:11.8877330Z 已启动使用 ZIP Deploy 的包部署。2019-11-22T22:44:42.6873709Z[错误]无法将 Web 包部署到应用服务。2019-11-22T22:44:42.6884687Z ##[错误]错误:错误:部署失败
Web 包到应用程序服务。错误:请求超时:/api/zipdeploy?deployer=VSTS&message=%7B%22type%22%3A%22deployment%22%2C%22commitId%22%3A%222509aae88d82fbff1a5b4567e66d506ab75d5eb7%22%2C%22buildId%22%3A%221 746%22 %2C%22releaseId%22%3A%22142%22%2C%22buildNumber%22%3A%221746%22%2C%22releaseName%22%3A%22Release-83%22%2C%22repoProvider%22%3A%22TfsGit%22 %2C%22repoName%22%3A%22XXXX-ServerV2%22%2C%22collectionUrl%22%3A%22https%3A%2F%2FXXXX.visualstudio.com%2F%22%2C%22teamProject%22%3A%22fa101fe3-6537 -4d7f-b39d-9825dde859d2%22%2C%22buildProjectUrl%22%3A%22https%3A%2F%2FXXXX.visualstudio.com%2Ffa101fe3-6537-4d7f-b39d-9825dde859d2%22%2C%22repositoryUrl%22%3A%22 %22%2C%22branch%22%3A%22重构%22%2C%22teamProjectName%22%3A%22XXXX%22%2C%22slotName%22%3A%22生产%22%7D 2019-11-22T22:44:44.0075802Z已成功向 Application Insight 添加发布注释: XXXX-webapp-test 2019-11-22T22:44:44.2965245Z 应用服务应用程序 URL:http: //XXXX-webapp-test.azurewebsites.net 2019-11-22T22:50: 48.0793152Z ##[节]完成:XXXX …
我在 .net core 3.0 上迁移 Xunit 集成测试时遇到了一个新问题。我将项目移动到子文件夹中,现在出现 DirectoryNotFoundException。
测试服务器夹具:
public class TestServerFixture : WebApplicationFactory<TestStartup>
{
public HttpClient Client { get; }
public ITestOutputHelper Output { get; set; }
protected override IHostBuilder CreateHostBuilder()
{
var builder = Host.CreateDefaultBuilder()
.ConfigureLogging(logging =>
{
logging.ClearProviders();
logging.AddXunit(Output);
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder
.UseStartup<TestStartup>()
.ConfigureTestServices((services) =>
{
services
.AddControllers()
.AddApplicationPart(typeof(Startup).Assembly);
});
});
return builder;
}
public TestServerFixture SetOutPut(ITestOutputHelper output)
{
Output = output;
return this;
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
Output = null; …Run Code Online (Sandbox Code Playgroud) 我针对集成测试升级到 .net core 3.0 时遇到的问题创建了一个存储库: https://github.com/ranouf/TestingWithDotNetCore3_0
当我启动测试时,我遇到了这个问题:消息:
System.AggregateException:发生一个或多个错误。(类装置类型“MyIntegrationTests.TestServerFixture”具有一个或多个未解析的构造函数参数:ITestOutputHelper 输出)(以下构造函数参数没有匹配的装置数据:TestServerFixture testServerFixture) ---- 类装置类型“MyIntegrationTests.TestServerFixture”具有一个或更多未解析的构造函数参数: ITestOutputHelper 输出 ---- 以下构造函数参数没有匹配的装置数据: TestServerFixture testServerFixture 堆栈跟踪: ----- 内部堆栈跟踪 #1 (Xunit.Sdk.TestClassException) ----- - ---- 内部堆栈跟踪 #2 (Xunit.Sdk.TestClassException) -----
这是构造函数:
public class WeatherForecastController_Tests : IClassFixture<TestServerFixture>
{
public WeatherForecastController_Tests(TestServerFixture testServerFixture, ITestOutputHelper output)
{
Client = testServerFixture.Client;
Output = output;
}
Run Code Online (Sandbox Code Playgroud)
测试启动:
public class TestStartup : Startup
{
public TestStartup(IConfiguration configuration)
: base(configuration)
{
}
public override void SetUpDataBase(IServiceCollection services)
{
// here is where I use the InMemoryDatabase
}
} …Run Code Online (Sandbox Code Playgroud) 我的服务器使用 .Net Core 2.1.402
这是我的 C# 类:
public class SampleDetailsDto
{
public Guid Id{ get; set; }
public string Text { get; set; }
public IEnumerable<string> ImageUrls { get; set; }
public IFormCollection Images { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
这是我的 C# 控制器
[HttpPut]
[Route("{id:guid}")]
public async Task<IActionResult> UpdateAsync([FromRoute]Guid id, [FromForm] SampleDetailsDtodto)
{
Console.WriteLine(dto.Text);
Console.WriteLine(dto.Images.Length);
return OK();
}
Run Code Online (Sandbox Code Playgroud)
我使用 nswag 生成客户端服务,但目前存在一个错误(https://github.com/RSuter/NSwag/issues/1421#issuecomment-424480418)上传多个文件,所以我扩展了更新方法来创建我的,这里是代码:
public update(id: string, dto: SampleDetailsDto | null | undefined): Observable<SampleDetailsDto | null> {
let url_ = this._baseUrl + …Run Code Online (Sandbox Code Playgroud) 我有一个 Azure 函数,每次更新我的 CosmosDb 集合中的多个项目时都会触发该函数。
代码正常工作:
[StorageAccount("AzureWebJobsStorage")]
public static class ChangeFeedFunction
{
[FunctionName("ChangeFeedFunction")]
public static void ChangeFeedFunction(
[CosmosDBTrigger(
databaseName: "MyDataBase",
collectionName: "MyCollection",
ConnectionStringSetting = "CosmosDbConnectionString",
LeaseCollectionName = "MyCollection_Leases",
CreateLeaseCollectionIfNotExists = true
)] IReadOnlyList<Document> documents,
[Queue("collection-changes")] ICollector<Message> analystQueue,
ILogger logger
)
{
//Operations;
}
Run Code Online (Sandbox Code Playgroud)
但在这种情况下,这意味着我有 2 个 CosmosDb 集合(MyCollection和MyCollection_Leases),每月最低 40 美元。我想降低成本。有没有办法在不使用其他 CosmosDb 集合的情况下观察我的 CosmosDb 集合上的修改?
谢谢
.net-core ×4
c# ×3
asp.net-core ×2
azure ×2
xunit ×2
angular ×1
appsettings ×1
azure-devops ×1
nswag ×1
signalr ×1
typescript ×1
webrtc ×1