0
在Azure中,我基于(VM)模板创建了Elasticsearch和Kibana集群。在我的单元测试中,我使用Elasticsearch NEST nuget包来访问我的天蓝色电子搜索。阿萍只是正常工作Azure Elasticsearch和NEST无法添加索引
var node = new Uri("http://x:5601");
var settings = new ConnectionSettings(node);
var client = new ElasticClient(settings);
var response = client.Ping(new PingRequest());
Assert.IsTrue(response.IsValid);
但是当我尝试添加一个索引,我总是得到错误“请求必须包含一个KBN-XSRF头” 我已经尝试了很多东西,并试图尽量多的例子,但与没有成功。我想知道的事情
- 哪个nuget版本应该与创建的VM一起使用。我想出了天蓝色的环境运行ES 1,所以我应该使用nuget包 1.82
- 我应该如何在我的代码中进行身份验证?我发现SetBasicAuthentication,还是这似乎并没有工作尤为明显
- 如何设置或KBN-XSRF工作
顺便说一下我的索引创建单元测试看起来像
var node = new Uri("http://x:5601");
var settings = new ConnectionSettings(node);
settings.SetBasicAuthentication("x", "x");
var client = new ElasticClient(settings);
var response = client.CreateIndex("hotelindex");
Assert.IsTrue(response.IsValid);