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 });
Related
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?
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
I am following the new Azure.ResourceManager SDK examples here.
I'm not seeing classes I'd expect to see in Azure.ResourceManager.Resources. Specifically, ArmDeploymentCollection and ResourceGroupResource doesn't have a GetArmDeployments() method.
Azure.ResourceManager installed is Azure.ResourceManager.1.0.0. I'm targeting .NET framework 4.8.
I've tried uninstalling/re-installing Azure.ResourceManager several times, but doesn't change anything.
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using System.Collections.ObjectModel;
using System.IO;
using Microsoft.Azure.Documents;
using Microsoft.Azure.Documents.Client;
using Microsoft.Azure.Documents.Linq;
using Microsoft.Azure.Management.ResourceManager.Fluent.Authentication;
using Microsoft.Azure.KeyVault;
using System.Threading;
using Azure;
using Azure.Identity;
using Azure.Core;
using Azure.ResourceManager;
using Azure.ResourceManager.Resources;
using Azure.ResourceManager.Resources.Models;
public static void Initialize()
{
try
{
// Authenticate
var credentials = new DefaultAzureCredential();
await RunSample(credentials);
}
catch (Exception ex)
{
Utilities.Log(ex);
}
}
public static async Task RunSample(TokenCredential credential)
{
try
{
var deploymentName = "bradDeployment";
var rgName = "rg-percipience-test-002";
var subscriptionId = Environment.GetEnvironmentVariable("AZURE_SUBSCRIPTION_ID");
var templateJson = Utilities.GetArmTemplate("ArmTemplate.json");
ArmClient armClient = new ArmClient(new DefaultAzureCredential());
SubscriptionResource subscription = await armClient.GetDefaultSubscriptionAsync();
ResourceGroupCollection rgCollection = subscription.GetResourceGroups();
// With the collection, we can create a new resource group with an specific name
AzureLocation location = AzureLocation.EastUS;
ArmOperation<ResourceGroupResource> lro = await rgCollection.CreateOrUpdateAsync(WaitUntil.Completed, rgName, new ResourceGroupData(location));
ResourceGroupResource resourceGroup = lro.Value;
Utilities.Log("Created a resource group with name: " + rgName);
// Create a deployment for an Azure App Service via an ARM
// template.
Utilities.Log("Starting a deployment for an Azure App Service: " + deploymentName);
// First we need to get the deployment collection from the resource group
ArmDeploymentCollection armDeploymentCollection = resourceGroup.GetArmDeployments();
// Use the same location as the resource group
// Passing string to template and parameters
var input = new ArmDeploymentContent(new ArmDeploymentProperties(ArmDeploymentMode.Incremental)
{
Template = BinaryData.FromString(File.ReadAllText("storage-template.json")),
Parameters = BinaryData.FromString(File.ReadAllText("storage-parameters.json"))
});
ArmOperation<ArmDeploymentResource> lro2 = await ArmDeploymentCollection.CreateOrUpdateAsync(WaitUntil.Completed, deploymentName, input);
ArmDeploymentResource deployment = lro2.Value;
Utilities.Log("Completed the deployment: " + deploymentName);
}
finally
{
try
{
Utilities.Log("Deleting Resource Group: " + rgName);
await (await resourceGroups.StartDeleteAsync(rgName)).WaitForCompletionAsync();
Utilities.Log("Deleted Resource Group: " + rgName);
}
catch (Exception ex)
{
Utilities.Log(ex);
}
}
}
I resolved the issue by adding a reference to Azure.ResourceManager.Resources.dll. Not sure why this reference isn't added when the nuget package is installed.
I recently download Nlog.dll from internet and add it into references part of project I'm writing code in C#. But even ready codes doesn't work in my simple console application. For the beginning I write it into my simple console application
As you can see here even some method of ondefined on other panel there is NLog classes located. How I can configure NLog from code?
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NLog;
using NLog.Config;
namespace ConsoleApplication1
{
class Program
{
private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();
static void Main(string[] args)
{
var config = new NLog.Config.LoggingConfiguration();
var logfile = new NLog.Targets.FileTarget("logfile") { FileName = "file.txt" };
var logconsole = new NLog.Targets.ConsoleTarget("logconsole");
config.AddRule(LogLevel.Info, LogLevel.Fatal, logconsole);
config.AddRule(LogLevel.Debug, LogLevel.Fatal, logfile);
NLog.LogManager.Configuration = config;
var logger = NLog.LogManager.GetCurrentClassLogger();
logger.Info("Hello World");
}
}
}
I get this error (in Russian language):
The code is correct for the latest version of NLog on NuGet. The .dll you downloaded seems to be an older version of NLog.
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