I have been working on adding Azure SignalR Service to one of my Azure functions. I am planning use this Azure Function for CosmosDB Change Feed feature. Whenever there is a change in my CosmosDB Container, Azure Function will run and check the changed data. You can have all kind of business rules here to do something about this change. This is great and I love this option, but I don't want to stop there, I want to notice my users immediately when there is a specific changes in data. My users use a web application to track important changes and I want my Azure Function to display a note or an image to the users in real time.
How to do that? Azure SignalR Service will help me with this. SignalR opens a websocket port between each user and Signalr service. My Azure function will send a message to Azure SignalR Service and SignalR service will send this message to a specific user or all users in real time. Javascript on the web application listens for any changes and catches the SignalR messages. As soon as a message is received, I can display it on the web page immediately. Users don't need to refresh their page to see the latest, just like Chatting tool messages will come up to their screen immediately.
To send a message to Azure SignalR service, I need to use SignalR references in my Azure function. I create my Azure functions at Portal and it might be a challenge to add any custom references or extensions from Azure Portal. I will add SignalR references in this post, but you can use the same method to add any Nuget references.
The extension I want to add to my function is located at this Nuget location. I need to install this package to my Azure function and I want to do that from Azure Portal without using Visual Studio, Visual Code or any other add-ons. It feels like a new dev tool comes up every month with no User Interface. All they give you is a command line then you need to learn its commands to use it. It's not that difficult to come up with a decent User Interface people. Okay enough whining, I will continue...
I want to introduce you Kudu, here is good a definition of Kudu from Microsoft. "Kudu is the central nervous system of a Microsoft Azure Web Site; it handles the Git integration to a Web Site as well as provides an API endpoint for programmatic access to app settings,"
Kudu can help you when you need to add references to your Azure functions. You can find a link to Kudu under Platform Features. Now, this will be a good time to stop this function because we need to add new references and rebuild it.
When link opens, click on Debug Console and pick CMD to see command prompt.
Now, I am ready to add any Nuget packages. Your Azure function should not be running in this point. First, we need to navigate to right folder. You want to be in D:\home\site\wwwroot folder to continue, you can navigate by clicking on folders or you can use your DOS skills to navigate to the folder by using the command prompt.
Next, you need to navigate to wwwroot folder and run the following command to build your Azure Function. Your Azure Function should not be running in this part!
dotnet build extensions.csproj -o bin --no-incremental --packages D:\home\.nuget
Kudu will rebuild your application and it will download and install all the packages including the all the other ones you just added. You should get Build succeeded message when it's completed. You just added a NuGet Package to your Azure Function. You should be able to use this in your code now. You can start your Azure Function now and start using this reference in your code!
Informative Blog...
ReplyDeleteMicrosoft Azure DevOps Training
Azure DevOps online training in hyderabad
Excellent Blog
ReplyDeleteAzure DevOps online training
Azure DevOps online training in hyderabad
Microsoft Azure DevOps training in hyderabad
Microsoft Azure DevOps Online Training
Microsoft Azure DevOps Training