Azure Text Moderator not found - azure

API Name:
TextModerator
have Azure Subscription and I created the cognitive service, and from a c# console, I'm trying to test the TextModerator project.
When this line is called:
var screenResult =
client.TextModeration.ScreenText("text/plain", new MemoryStream(Encoding.UTF8.GetBytes(text)), "eng", true, true, null, true);
I got the following message:
Microsoft.CognitiveServices.ContentModerator.Models.APIErrorException
: 'Operation returned an invalid status code 'NotFound''
the endpoint is like this:
https://contentmoderator-****.cognitiveservices.azure.com/contentmoderator
Any Idea?
Saad

You can use the following base endpoint for your specific Region(ex:westus).
https://westus.api.cognitive.microsoft.com.
Install the client library:
Within the application directory, install the Content Moderator client library for .NET with the following command:
dotnet add package Microsoft.Azure.CognitiveServices.ContentModerator --version 2.0.0
If you're using the Visual Studio IDE, the client library is available as a downloadable NuGet package.
Please follow the below document for Moderate Text.
https://learn.microsoft.com/en-us/azure/cognitive-services/content-moderator/dotnet-sdk-quickstart#setting-up
Please follow the API Reference for more information.

Related

Orika data mapping error after installing cmsoccaddon on custom commercewebservices on Hybris 2005

We are using the custom commercewebservice extended from ycommercewebservice. We are not using the CMS API as of now but we have we need CMS APIs for spartacus.
I have install cmsoccaddon on our customer webservice extension. Addon install successfully but when we try to access https://localhost:9002/rest/v2/{base_site}/cms/pages it will throws the error:
ma.glasnost.orika.MappingException: While attempting the following mapping: sourceType = de.hybris.platform.cmsfacades.data.PageContentSlotData sourceProperty = slotShared(boolean) destinationType = java.util.ArrayList<ContentSlotWsDTO> destinationProperty = 8(ContentSlotWsDTO) Error occurred: ma.glasnost.orika.MappingException: Encountered mapping of primitive to object (or vise-versa); sourceType=boolean, destinationType=ContentSlotWsDTO
Fetch component API is working fine with the cmsaddon (https://localhost:9002/rest/v2/{base_site}/cms/components?fields=DEFAULT&componentIds={componentId})
We Just update hybris version to 2005
Since you migrated from 1905 to 2005, the endpoints prefix has been changed from /rest/v2/ to /occ/v2.
More information can be found in the following:
help.sap (2005) https://help.sap.com/docs/SAP_COMMERCE/e5d7cec9064f453b84235dc582b886da/d46d19516961438f8939718e87ed787b.html?version=2005
https://help.sap.com/docs/SAP_COMMERCE/9d346683b0084da2938be8a285c0c27a/9136088a207c4fc1bb5ec2b53c462b23.html?version=2005

Swashbuckle for Azure Functions v3: failed to load API definition

I created a simple project where I added the latest version of the extension. I published my code on Github. I use Azure Functions v3. The dependencies are:
AzureExtensions.Swashbuckle 3.1.6
AzureFunctions.Extensions.Swashbuckle 1.4.4
Microsoft.NET.Sdk.Functions 3.0.3
I followed the steps on theSwashbuckle page. Locally is working. When I publish the function on Azure, I get this error:
{
"schemaValidationMessages": [
{
"level": "error",
"message": "Can't read from file https://azuks-test-q001.azurewebsites.net/api/swagger/json"
}
]
}
Before this, I faced another issue that I asked here. I can't understand what changed.
Update
For same reason, the code param can't be the same for json and UI. If you open your Swagger url with Get Function url and copy the url from UI function, it is working.
Currently only fork => https://github.com/vitalybibikov/azure-functions-extensions-swashbuckle
supports your version of Azure Functions, (which is v3)

how to configure loopback 4 with firestore datasource

I am trying to configure loopback4 with firestore data source using loopback-connector-firestore connector. when i am trying to post it is showing error code 500 with Error: Internal Server Error. Please tell me where i am exactly doing wrong.
It is simple.
First follow the steps to create datasource running the console command lb4 datasource.
When the command line ask you for the connector select other.
When the command line ask you for the connector's package name paste this loopback-connector-firestore. Please note that all connector for loopback 3 must work in loopback 4.
Then you should use a service account. Go to Project Settings > Service Accounts and press the Generate new private key button, in the Google Cloud Platform Console. Generate a new private key and save the JSON file.
Then in the src/datasources project folder open your new datasourceName.datasource.json file and add the following keys that you can find in the downloaded JSON file from the Google Cloud Platform in the previous step:
{
"projectId": "",
"clientEmail": "",
"privateKey": "",
"databaseName": "Optional, Default: projectId"
}
That is all. Now, if you have models, repositories and controller previously created you can run npm start, open the explorer and test your endpoints.
Regards.

dynamic_template_data doesn't work with sendgrid and azure function integration

Trying to use transactional template with azure function sendgrid integration (javaScript) , I'm sending the following object (removed email address etc.):
const message =
{
"personalizations":[
{
"to":[
{
"email":"[MY_EMAIL]",
"name":"Rotem"
}
],
"dynamic_template_data":{
"rotem_test1":"wow"
}
}
],
"from":{
"email":"[FROM_EMAIL]",
"name":"name"
},
"reply_to":{
"email":"[REPLY_EMAIL]",
"name":"name"
},
"template_id":"[CORRECT_TEMPLATE_ID]",
"tracking_settings":{
"click_tracking":{
"enable":true
}
}
}
context.done(null,message);
also tried using context.done(null,JSON.stringify(message)) with the same result:
I get an email from the correct template but without any substitution.
when sending the exact same object using the https://api.sendgrid.com/v3/mail/send
API using postman everything works well.
would love to get help here as for what I'm doing wrong on my azure function.
You did everything correctly as you can receive email as expected.
Problem is caused by the SDK version. Property dynamic_template_data has just been added in latest 9.10.0 Sendgrid C# SDK, but the binding extension still uses old version, which has no idea what dynamic_template_data is.
For 2.x function(Check Function app settings on Azure portal, see Runtime version: 2.xxx (~2)), we can install new version SDK manually before the extension is updated.
If you develop locally
Go to function project directory, delete bin, obj folder.
Edit extensions.csproj under function project, add latest version Sendgrid <PackageReference Include="Sendgrid" Version="9.10.0" />.
In this directory open console(terminal,Powershell,etc), input func extensions install to restore packages.
Else on Azure portal
Stop the function app.
Access kudu console through Platform Features -> Advanced Tools(Kudu) -> Debug Console (CMD)
Navigate to D:\home\site\wwwroot
Delete the bin directory
Edit extensions.csproj, add <PackageReference Include="Sendgrid" Version="9.10.0" /> and Save the changes.
In console below, input dotnet build extensions.csproj -o bin --no-incremental --packages D:\home\.nuget
After you see Build succeeded, start the function app.
For 1.x function(Runtime ~1), I am afraid we have to manually send email using with sendgrid node module, Sendgrid vesion in 1.x function is locked therefore can't be updated.

Error w/ Azure CLI on importing publish settings file

This is similar to the issue this SO user was having except I'm getting a different error for the same behavior.
I downloaded the publishsettings file from azure and
Issued this command in the azure cli: azure account import <MySite>.azurewebsites.net.PublishSettings
and I got the following error:
{ name: 'AssertionError',
message: undefined,
actual: 'UNIVERSAL-primative-0',
expected: 'UNIVERSAL-primative-6',
operator: '==' }
AssertionError: "UNIVERSAL-primative-0" == "UNIVERSAL-primative-6"
...Shortened for brevity. Let me know if you'd like the full stack trace...
I wasn't particularly anxious to wrap this node project in a VisualStudio project, but I think in a pinch, I could and just format the publish settings from within VS. But if there is a way to do this correctly, I'd prefer that.
Where did you get the file? Were you using the following command to get it?
azure site download
It seems like you are using the publishsettings file of an Azure Web Site while xplat-cli expects the publishsettings file of the subscription.
There are kinds of 2 publishsettings files. And yeah, it's confusing.

Resources