Package to help developers create solutions faster, and enforcing Logging and Exception Handling, while still allowing the developers to have the control over the configuration. Designed to be consumed from microservices, so most items are async and do as little as possible, unless you configure it to do more, for example, in the case of Twitter Services, they support retry configuration, and have out of the box support for waiting for Twitter API Rate Limit, thanks for the great work done by Joe Mayo (https://github.com/JoeMayo) with his LinqToTwitter library.
Install the desired packages prefixed with "PTI.Microservices.Library." starting with the version "2.0.0.0-preview"
You can help improving the libraries by adding issues, feature requests and implementing functionality in each of the repositories here https://github.com/efonsecab?tab=repositories&q=PTI.Microservices.Library&type=&language=&sort=
- Set your RapidApiKey.
- Register Services (or manually create services instances)
The services configuration classes have an endpoint property, in the case of Azure services, those will usually be the Url for your created resource in Azure, or the base azure service api. In the case of the specialized services such as Customer Finder, Emotions Analyzer, Books Translation and similar, the property is prefilled with the Rapid API base service, if you use appSettings-based configuration the default value will be overwritten to respect developer-based configuration, this means you will need to set the correct service Url when using appSettings-based configuration.
//The given key is for demo purposes and will stop working eventually.
//To get your own key request it by writing to [email protected]
GlobalPackageConfiguration.RapidApiKey = "a3893edcbfmsh2efa1861dcc7a10p159864jsnf17e667d1bf7";
services.AddSingleton(twitterConfiguration);
services.AddLogging();
services.AddTransient<ILogger, Logger<TwitterPossibleFakeAccount>>();
services.AddTransient<CustomHttpClientHandler>();
services.AddTransient<CustomHttpClient>();
services.AddTransient<TwitterService>();
services.AddTransient<TwitterPossibleFakeAccountService>();
[HttpPost("[action]")]
public async Task<IActionResult> UploadImages([FromBody]UploadImagesModel model)
{
Guid projectId = Guid.Parse(model.ProjectId);
List<Uri> lstImages = model.Items.Where(p=>p.IsSelected==true).Select(p => new Uri(p.ImageUrl)).ToList();
var uploadImagesResult = await AzureCustomVisionService.UploadImagesAsync(lstImages, projectId);
List<string> tags = new List<string>() { model.Tag };
foreach (var singleImage in uploadImagesResult)
{
try
{
await this.AzureCustomVisionService.CreateImageTagsAsync(projectId,
singleImage.Image.Id,
tags);
await Task.Delay(TimeSpan.FromSeconds(1));
}
catch (Exception ex)
{
this.Logger.LogError(ex, ex.Message);
}
}
return Ok();
}
await twitterFakeFollowersService.GetAllPossibleFakeFollowersForUsernameAsync(this.TwitterConfiguration.ScreenName,
(possibleFakeUser) =>
{
//Your custom logic to execute when a new possible twitter fake user has been detected
}, cancellationToken: cancellationTokenSource.Token);
AudibleWeatherService audibleWeatherService = new AudibleWeatherService(logger, azureMapsService, azureSpeechService);
await audibleWeatherService.SpeakCurrentWeatherAsync(geoCoordinates);
var result = await booksTranslationService.TranslateDocXFileFromUrlAsync(fileUrl, TranslationLanguage.English, TranslationLanguage.Spanish,
BookTranslationMode.KeepFormatting, emailAddress:"[email protected]");
var allKeywords = await azureVideoIndexerService.GetAllKeywordsAsync(onNewKeywordFound:(keyword)=>
{
//Your custom code to execute when a keyword has been processed.Added so that you do not have to wait for the whole process to finish
});
var result =
await emotionsAnalyzerService.AnalyzeFileFromUrlAsync(fileUrl,
model: new Microservices.Library.Models.EmotionsAnalyzer.AnalyzeFileModel()
{
SourceFileUrl=fileUrl,
EmailForResults="[email protected]",
AnalysisWorksheet =
new Microservices.Library.Models.EmotionsAnalyzer.AnalysisWorksheet()
{
ColumnToAnalyze="PostText",
ColumnWithDate="RecordDate",
ColumnWithUniqueId="RecordUniqueId",
SentimentPlaceholderColumn="SentimentAnalysisPlaceHolder",
WorksheetName="FacebookPosts"
},
PlaceWorksheet=new Microservices.Library.Models.EmotionsAnalyzer.PlaceWorksheet()
{
SentimentPlaceholderColumn="PlaceSentimentPlaceHolder",
WorksheetName="PlaceSentiment"
}
});
TwitterDataAnalysisService twitterDataAnalysisService = new TwitterDataAnalysisService(
logger, twitterService, azureTextAnalyticsService);
var twitterUserTopics = await twitterDataAnalysisService.GetTopicsForUserAsync("twitterusername");
More samples at https://github.com/efonsecab/PTI.Microservices.Library/blob/master/README.md
The following are sample applications of things you could do with the package
- Search Images on Bing and feed your Custom Vision Models: https://github.com/efonsecab/BlazorCustomVisionUploader
- Search Images on Bing and feed your Azure Video Indexer Person Models: https://github.com/efonsecab/BlazorVideoIndexerUploader
For inquiries, and business deals, you can write an email to [email protected]