C# Kafka Producer using AWS MSK - c#

I am currently trying to implement a C# dotnet Kafka producer which connects to my AWS MSK brokers.
The template code I am using is, with utilizes the Confluent.Kafka library:
var producerConfig = new ProducerConfig
{
SecurityProtocol = SecurityProtocol.SaslSsl,
ClientId = "table-producer",
BootstrapServers = "broker-1.host:port,broker-2.host:port,broker-3.host:port"
};
using (var producer = new ProducerBuilder<Null, dynamic[]>(producerConfig).Build())
{
}
I can't seem to find any documentation on how to authenticate against AWS MSK using IAM. Does the dotnet Confluent.Kafka library even support this?

Related

Dynamics 365: why I get "Xrm.Sdk WSDL" error for .net6 console client?

Mac OS, .Net6, C# 10.0.
I always created console clients for MS Dynamics 365 on .Net Framework Platform without problems. But now I need to do the same on .Net Core or newer platform (because I need to put it into Docker container later). At this case I try to use .Net6.
I created new console application and added the NuGet packages:
Microsoft.PowerPlatform.Dataverse.Client v0.6.6
System.Configuration.ConfigurationManager v6.0.0
System.ServiceModel.Primitives v4.9.0
My simple Program.cs file:
using System.Net;
using System.ServiceModel.Description;
using Microsoft.Crm.Sdk.Messages;
using Microsoft.Xrm.Sdk.Client;
namespace ConsoleAppExample
{
internal class Program
{
static void Main(string[] args)
{
Console.Title = "CRM console client";
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
var orgServiceUrl = "http://dev-crm-app02/MyCompany/XRMServices/2011/Organization.svc";
var crmUserLogin = "myLogin";
var crmUserPassword = "myPassword";
var credentials = new ClientCredentials();
credentials.UserName.UserName = crmUserLogin;
credentials.UserName.Password = crmUserPassword;
try
{
using (var orgService = new OrganizationServiceProxy(new Uri(orgServiceUrl),
null, credentials, null))
{
RetrieveVersionRequest versionRequest = new RetrieveVersionRequest();
RetrieveVersionResponse versionResponse =
(RetrieveVersionResponse) orgService.Execute(versionRequest);
WhoAmIRequest whoAmIRequest = new WhoAmIRequest();
WhoAmIResponse whoAmIResponse = (WhoAmIResponse) orgService.Execute(whoAmIRequest);
Console.WriteLine($"\nOrganizationService: {orgServiceUrl}");
Console.WriteLine($"CRM version: {versionResponse.Version}");
Console.WriteLine($"User login: {crmUserLogin}");
Console.WriteLine($"\nOrganizationId: {whoAmIResponse.OrganizationId}");
Console.WriteLine($"BusinessUnitId: {whoAmIResponse.BusinessUnitId}");
Console.WriteLine($"UserId: {whoAmIResponse.UserId}");
}
}
catch (Exception ex)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(ex.Message); // Xrm.Sdk WSDL
if (ex.InnerException != null)
{
Console.WriteLine(ex.InnerException.Message);
}
Console.ResetColor();
}
Console.WriteLine("\nPress ENTER for exit...");
Console.ReadLine();
}
}
}
But when I run my application I get the error:
Xrm.Sdk WSDL
Why does it happen and how can I solve it?
Organization service client is deprecated and is not supported directly on net core.
When connecting using the dataverse serviceclient, connection string or serviceclient constructor is the only supported way.
That said onprem is not well supported due to the changes I the underlying authentication stack.
Best currently possible supported feature is to use oAuth via adfs on prem with a custom auth handler.
There is an extension written by a user of the dataverse service client that adds AD and WSTrust support for net core, but it is not part of the MS distribution.
You can find a link to it on the dataverse serviceclient GitHub site issues board under the AD onPrem support topic
https://github.com/microsoft/PowerPlatform-DataverseServiceClient/issues/110

Need to configure Jaeger with c# application

I have a c# sample app that can send the trace to the console. How can i send the trace to the Jaeger running locally?
i am using Jaeger running locally at jaeger-all-in-one --collector.zipkin.host-port=:9411
using System.Diagnostics;
using OpenTelemetry;
using OpenTelemetry.Trace;
using OpenTelemetry.Resources;
using OpenTelemetry.Exporter;
// Define some important constants and the activity source
var serviceName = "MyCompany.MyProduct.MyService";
var serviceVersion = "1.0.0";
// Configure important OpenTelemetry settings and the console exporter
using var tracerProvider = Sdk.CreateTracerProviderBuilder()
.AddSource(serviceName)
.SetResourceBuilder(
ResourceBuilder.CreateDefault()
.AddService(serviceName: serviceName, serviceVersion: serviceVersion))
.AddConsoleExporter()
.Build();
var MyActivitySource = new ActivitySource(serviceName);
using var activity = MyActivitySource.StartActivity("SayHello");
activity?.SetTag("foo", 1);
activity?.SetTag("bar", "Hello, World!");
activity?.SetTag("baz", new int[] { 1, 2, 3 });

HoloLens cannot connect to OpcUa server

I want to connect to the OpcUa server through the APP on HoloLens and read the node's data. It works on Unity and works fine, but it can't connect to the OpcUa server in HoloLens. I use the OpcUaHelper plugin, which has a simple OpcUa client and supports .Net Core and .Net Standard 2.0.
Unity's settings are:
Scripting Runtime Version: .Net 4.X Equivalent
Scripting Backend: IL2CPP
Api Compatibility Level : .Net 4.X
My code are shown below.
Does anyone know what the reason is?
Or have anyone tried to connect the Opc Ua server in HoloLens?
The version of the software I am using is:
1.Unity 2018 3.11f
2.Mixed Reality Toolkit v2.0.0 RC1
3.Visual Studio 2017
using System;
using UnityEngine;
using UnityEngine.UI;
using Microsoft.MixedReality.Toolkit.Input;
using OpcUaHelper;
using Opc.Ua;
using System.Collections;
using System.Collections.Generic;
public void OpcUaConnector()
{
OpcUaClient m_OpcUaClient = new OpcUaClient();
//m_OpcUaClient.UserIdentity = new UserIdentity("user", "password");
string OpcUa_Test = "opc.tcp://118.24.36.220:62547/DataAccessServer";
m_OpcUaClient.ConnectServer(string.Format("{0}", OpcUa_Test));
try
{
//Read the same type of data from multiple nodes
List<NodeId> nodeIds = new List<NodeId>();
nodeIds.Add(new NodeId("ns=2;s=Machines/Machine A/Name"));
nodeIds.Add(new NodeId("ns=2;s=Machines/Machine B/Name"));
nodeIds.Add(new NodeId("ns=2;s=Machines/Machine C/Name"));
List<DataValue> dataValues = m_OpcUaClient.ReadNodes(nodeIds.ToArray());
AnlagenName_A.text = string.Format("{0}", dataValues[0]);
AnlagenName_B.text = string.Format("{0}", dataValues[1]);
AnlagenName_C.text = string.Format("{0}", dataValues[2]);
//foreach (string tag in Tags)
//{
// string value = m_OpcUaClient.ReadNode<string>(tag);
//}
}
// //Read data from a single node
// //string value = m_OpcUaClient.ReadNode<string>("ns=2;s=Machines/Machine B/Name");
// //Console.WriteLine("{0}", value);
// //Console.ReadKey();
//}
catch
{
Debug.Log("Connected Failed");
}
}
I hope to successfully connect to the OpcUa server and read the node data.

No jobs functions found

I am trying to make scheduled mail with azure functions on Visual Studio but this time I took No Jobs functions found error. How can I fix and send this mails?
Also I made this function on Azure Portal and it works. I'm trying to convert Visual Studio.
using System;
using SendGrid.Helpers.Mail;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Azure.WebJobs;
namespace FifteenMinMail
{
public class Program
{
public static void Main()
{
JobHostConfiguration config = new JobHostConfiguration();
config.UseTimers();
JobHost host = new JobHost(config);
host.RunAndBlock();
}
}
public class ScheduledMail
{
public static Mail Run(TimerInfo myTimer, TraceWriter log)
{
JobHostConfiguration config = new JobHostConfiguration();
config.UseTimers();
JobHost host = new JobHost(config);
var today = DateTime.Today.ToShortDateString();
log.Info($"Generating daily report for {today} at {DateTime.Now}");
Mail message = new Mail()
{
Subject = "15 DK'LIK TEST MAILI"
};
Content content = new Content
{
Type = "text/plain",
Value = "Bu mail 15 dk da bir yinelenecektir."
};
message.AddContent(content);
return message;
}
}
}
Error; https://imgur.com/pyyctnC
you are mixing up web jobs and azure functions.
those are different but related technologys.
have a look at this if you want to create an azure function in visual studio:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-your-first-function-visual-studio

Amazon S3 returns "SignatureDoesNotMatch" on download using mono

I am downloading files from S3 using this code
protected void FileDownload(FileInfo localFile)
{
using (AmazonS3Client s3Client = new AmazonS3Client(this.accessKey, this.secretKey, this.regionEndpoint))
{
using (GetObjectResponse response = s3Client.GetObject(this.bucketName, this.key))
{
response.WriteResponseStreamToFile(localFile.FullName);
}
}
}
From windows everything works, but when using mono on ubuntu then S3 responds with a http-403 saying "SignatureDoesNotMatch". Any idee?
I am using ubuntu-14.04, mono 3.12.1, .net4.5 and AWSSDK 2.3.24.1

Categories