Swashbuckle for Azure Functions v3: failed to load API definition - azure

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)

Related

NuxtJS & Firebase : upgrading to NodeJS 16 engine breaks Firestore listener (Firebase rules)

I've been using NuxtJS (v2.15.8) with Nuxt Firebase (v7.6.1), running on NodeJS engine 12 (v12.21.0 to be exact) for the web application I've been developping incrementally for the past couple of years and my web app is now quite complex.
I am trying to upgrade NodeJS to the latest LTS version (v16.13.2) and encounter one major issue after switching version of NodeJS (using nvm) and changing the package.json of my five packages from node 12 to node 16 :
package.json :
"engines": {
"node": "16",
..
},
When running exactly the wame web application after these changes, it starts correctly but Firebase Rules seem to break, with this error FirebaseError: false for 'get' # L61, false for 'get' # L268.
It is a cryptic error, but from experience and from all I could find online, it happens when a call to Firestore that gets blocked by defined Firebase Security rules). In my case, it happens on a "onSnapshot" call to listen to the changes of the currently logged in user. Some other calls to Firestore (using "get" and not "onSnapshot") seem to work fine, and the Firebase Authentication works well too.
Here is the full error stack :
loggedInUser.js?384a:65 Error listening to user changes
FirebaseError: false for 'get' # L61, false for 'get' # L268
at new n (prebuilt-306f43d8-45d6f0b9.js?23bd:188:1)
at eval (prebuilt-306f43d8-45d6f0b9.js?23bd:10426:1)
at eval (prebuilt-306f43d8-45d6f0b9.js?23bd:10427:1)
at n.onMessage (prebuilt-306f43d8-45d6f0b9.js?23bd:10449:1)
at eval (prebuilt-306f43d8-45d6f0b9.js?23bd:10366:1)
at eval (prebuilt-306f43d8-45d6f0b9.js?23bd:10397:1)
at eval (prebuilt-306f43d8-45d6f0b9.js?23bd:15160:1)
at eval (prebuilt-306f43d8-45d6f0b9.js?23bd:15218:1)
The portion of code triggerring the error is :
listenUser({ commit }, userId) {
const userRef = this.$fire.firestore.collection('users').doc(userId);
userListener = userRef.onSnapshot(function(userDoc) {
if (userDoc.exists) {
const user = userConverter.fromFirestoreData(userDoc.data());
commit('SET_LOGGED_IN_USER', user);
}
},
function(error) {
console.error("Error listening to user changes", error);
});
},
As soon as I revert back to Node 12, the same call works fine and isn't blocked by the Firebase rules, so the error doesn't appear.
I therefore have several questions :
Does anyone understand what's happening there ? Is there known changes in the behavior of Firebase rules directly related to the NodeJS engine ?
Do you think this issue can come from Nuxt or its Nuxt Firebase module are not working correctly under NodeJS 16 ?
It is required to also upgrade NuxtJS to a newer version or should it be possible to simply update the Node Engine ?
Is it required to update to a newer version of Firebase (modular implementation) despite the Nuxt Firebase module stating :
"This module does not support the new modular syntax from Firebase v9+. If you plan to use the new modular mode of Version 9, we advise you to implement Firebase manually as described in the following medium article. It is currently unclear when, and if, this module will support the new modular mode."
Source : their Github repo
Any help to understand what's going on here is welcome !!
Thanks a lot for your help !
Regarding your questions:
I'm unaware of what is causing this issue but there are no known changes in the behavior of Firebase Rules depending on the NodeJS version you are using.
It's hard to assess without having more information. However I deployed a sample NuxtJS app following this guide on NodeJS 16 and it worked. Additionally the error code, as you mentioned, is caused when a Firestore Rule blocks a query. Therefore I think the root cause might be in the NuxtJS firebase module.
I wasn't able to find any documentation suggesting that you need to upgrade NuxtJS when upgrading NodeJS. Additionally you mentioned that you are using version 2.15.8 of NuxtJS which according to this release notes is the latest version.
I'm unsure on further support for NuxtJS considering that statement, but according to this Firebase documentation it is recommended to upgrade to version 9.
If you decide to attempt to upgrade to firebase v9 make sure to also upgrade Nuxt Firebase module to version 8.0.0 or higher, this version provides support to the compat library so you can use Firebase v9 although still with the old syntax, more information can be found here.
Lastly, if you'd like to test if a Firebase rule is working as expected you can quickly test it using the Rules Playground.
Long story short : upgrading to Firebase v9 worked.
Before I did that, I got stuck with rules preventing me to access firestore documents as soon as I tried running the project under Node16 engine.
So I had to do the following changes :
updating Firebase to v9
implement the configuration through a plugin rather than the nuxt-firebase module
make all the required changes in my code to make use of v9 modular (I didn't try using the compat version)
Now that I use the latest version of Firebase, I tried again switching to NodeJS 16 and it runs fine, including the Firebase security rules.

Azure Text Moderator not found

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.

React native azure notification hub

I am using this library to implement azure notification hub in react native.
I am able to get the registration ID successfully. But no notification is received.
I am sending test notification from azure portal and it is getting delivered successfully.
I am followed the integration tutorial from here and here.
In my manifest file i am getting this error in red. Could be the reason.
If yes, How do i resolve this ?
I followed the same steps and had the same issue with com.microsoft.windowsazure.notifications.NotificationsBroadcastReceiver being unreferenced. I was able to resolve by adding
dependencies {
...
implementation 'com.microsoft.azure:notification-hubs-android-sdk:0.6#aar'
implementation 'com.microsoft.azure:azure-notifications-handler:1.0.1#aar'
}
repositories {
maven {
url "https://dl.bintray.com/microsoftazuremobile/SDK"
}
}
to my app build.gradle as outlined here
It may or may not make a difference but also make sure you have the x86 Atom image installed to the project

sass/node-sass issues downloading v4.10.0 from github api

Am trying to use the github api to download the node-sass dependency v4.10.0
Using the github api i am able to get the latest release v4.11.0 by using latest as the release name, however the tag v4.10.0 or any other tag is not working with api calls to single release download. How to fix this.
Below works
https://api.github.com/repos/sass/node-sass/releases/latest
Below doesn't where v4.10.0 is a valid release tag
https://api.github.com/repos/sass/node-sass/releases/v4.10.0
Error
{
"message": "Not Found",
"documentation_url": "https://developer.github.com/v3/repos/releases/#get-a-single-release"
}
I found the answer thought I would post here so it would be useful to others, according to the documentation we can use tags to get individual versions
The below worked for me
https://api.github.com/repos/sass/node-sass/releases/tags/v4.10.0
Use this API and download URL we should be able to fetch all the dependencies if have issues with proxy or access gyp for node sass.

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.

Resources