I got a system in Azure cloud which has a docker and each pod in the docker is a different service implemented with c# .Net Core. One of these services is a gRPC service which is a file service and every other service who want to access a file are using an SDK which access that service directly and it allows to access the requested file. The SDK is a nuget which every service adds to its references.
A flow example: Service A => invoke a method from SDK => Calls file service which access a file => return a response to the SDK => return a response to service A.
My desired behavior: I want to identify in the SDK the service itself which invokes the SDK's method. I can't use a simple input like just passing a string parameter because it's important to know the true service and I can't risk someone sending wrong information.
this is a pseudo code of what I need:
//this is an SDK method
public string GetSomeValueFromFile(string fileName)
{
string invokingService = GetCurrentService();
...
...
}
And the question is how to implement this GetCurrentService() method since I have no idea where to start
Related
I'm working on an API for an Azure Static Web App. The web app is implemented in Angular (although that isn't important for this question), and the API is implemented in C# (NET 6). Deployment to Azure is via a GitHub action.
I can create an HTTP trigger API endpoint that works fine, like so:
public static class Tester
{
[FunctionName("Tester")]
public static IActionResult Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", Route = "v1/tester")] HttpRequest req,
ILogger log)
{
return new OkObjectResult("Hello World");
}
}
I'm also able to access this directly via the SWA URL: https://<sitename>.azurestaticapps.net/api/v1/tester.
However, as soon as I add a reference to an Azure storage NuGet package to the project file (specifically Microsoft.Azure.WebJobs.Extensions.Storage.Blobs), making no other changes to the code, the API endpoint no longer works once deployed (although it will work locally).
On deploying the code with that package referenced in the .csproj, hitting the API endpoint gives a 503 status code with the response:
Function host is not running.
I enabled Application Insights for this static web app, and a CryptographicException is being thrown on startup:
An error occurred while trying to encrypt the provided data. Refer to the inner exception for more information. For more information go to http://aka.ms/dataprotectionwarning Could not find any recognizable digits.
(The link in the message doesn't go anywhere useful).
I'm presuming this has something to do with the AzureWebJobsStorage setting, which cannot be set in an Azure Static Web App (for whatever reason).
Based on all of the above, it would seem that using Azure storage from within a static web app C# function is verboten. However, I can't find that stated explicitly online anywhere. Has anybody got this kind of thing to work?
I removed the following nuget packages to make it working:
Microsoft.Azure.EventGrid
Microsoft.Azure.WebJobs.Extensions.EventGrid
I decomposed my http functions to a separate project because SWA does not support the EventTriggers right now.
According to the Azure DevOps Services REST API Reference, the request URI has the following format:
https://{instance}[/{team-project}]/_apis[/{area}]/{resource}?api-version={version}
Regarding the api-version:
Every API request should include an api-version to avoid having your app or service break as APIs evolve.
I started using the .NET client libraries for Azure DevOps Services (and TFS) to manage dashboards programmatically.
I am able to connect to Azure DevOps using a Personal Access Token:
var credential = new VssBasicCredential(string.Empty, "PersonalAccessToken");
using (VssConnection connection = new VssConnection(new Uri("...."), credential))
using (var client = connection.GetClient<DashboardHttpClient>())
{
// ...
}
How can I specify the API version? Does it still make sense to do it, when using the .NET client libraries?
The API version is decided by the client libraries. You can confirm this by disassembling them (e.g. using ILSpy).
For example, in the current stable release of Microsoft.TeamFoundationServer.Client, DashboardHttpClientBase has a CreateDashboardAsnc method that makes the following call:
this.SendAsync<Dashboard>(..., new ApiResourceVersion("4.1-preview.2"), ...);
I have a method called ReadFileData(string blobStorageFilePath) in my .NET Web API project. This method reads the text content from Azure Blob file. The azure blob storage file path is passed via the parameter in this method. Till now a client application (web) was calling this method to read file data but now I have to automate this process.
So, is it possible to call this web API method (by some way) whenever a new file is added to azure blob storage automatically? So this way there will be no need of any client application.
Which approach should I use to implement this process?
Any working example will be appreciated.
You can add a webjob to your Azure app service and install the Azure Webjobs SDK. Then you can easily trigger your read with a simple declarative blob trigger
https://learn.microsoft.com/en-us/azure/app-service-web/websites-dotnet-webjobs-sdk-storage-blobs-how-to
public static void CopyBlob([BlobTrigger("input/{name}")] TextReader input,
[Blob("output/{name}")] out string output)
{
output = input.ReadToEnd();
}
https://learn.microsoft.com/en-us/azure/azure-functions/functions-create-storage-blob-triggered-function
You can create a function triggered by Azure Blob storage. Please see the link for the complete example
I just got started with Application Insights and wanted to highlight dependencies between different operations. Currently I am using this code:
using (var x = telemetry.StartOperation<DependencyTelemetry>("my TEst")) {
x.Telemetry.Type = "SQL";
}
setting the Telemetry.Type to "SQL" makes the dependency appear as SQL DB which is fine and exactly what I want.
But I could not find any information about what other "Types" are supported here and what their exact Type would be?
e.g Blob Stores? Web APIs?
thanks in advance,
-gerhard
There's no limitation that I'm aware of.
Some dependencies are reported automatically by the SDK (such as SQL, Ajax), so these will get a pretty name in Application Map, but you can put there whatever makes sense in your application's BL.
The list of out-of-the-box dependency types Application Insights collect right now can be found here, although the documentation does not contain the dependency type string that you're interested in.
Non definitive list from my own experience:
SQL
HTTP
Azure queue
Azure table
Azure blob
Azure DocumentDb
Ajax
Redis
Azure Service Bus
MySQL
Azure IoT Hub
Azure Event Hubs
The are dependency types getting custom icons in Application Map:
- SQL
- Custom HTTP types, based on the following criteria:
1. Azure blob: when host name ends with blob.core.windows.net
2. Azure table: when host name ends with table.core.windows.net
3. Azure queue: when host name ends with queue.core.windows.net
4. Web Service: when host name ends with .asmx or contains .asmx/
5. WCF Service: when host name ends with .svc or contains .svc/
- All other HTTP or AJAX
Going forward the list will be extended with other dependency types that will get custom item in ApplicationMap.
I am developing a c# desktop application and using a webservies which is developed in a php application when i try to consume that application. I just add web REference of that web service and try to access throught the following code
WebReference.TestWSDL pdl = new testingApp.WebReference.TestWSDL();
string copy = pdl.verify("testing");
it throws the error when i try to call the method verify. the error is
Possible SOAP version mismatch: Envelope namespace http://schemas.xmlsoap.org/wsdl/ was unexpected. Expecting http://schemas.xmlsoap.org/soap/envelope/.
and the web service link was like
http://171.139.101.12/code/index.php/webservice/wsdl
The error you are encountering is informing you that when you invoke the webservice, you are being given the WSDL (Web Service Definition Language) for the service - this is the metadata that describes the service functions, but cannot actually be used to invoke the service. Usually, you access the WSDL by appending either "?wsdl" or "wsdl" to the service URI.
There are two elements to the webservice you are attempting to consume.
The actual service exists at:
http://171.139.101.12/code/index.php/webservice
The metadata describing it, which Visual Studio via wsdl.exe used to generate a proxy, resides here:
http://171.139.101.12/code/index.php/webservice/wsdl
You need to edit the properties of the Web Reference and update the address appropriately. Alternatively, you can alter the properties of the pdl variable, and change the endpoint in code.