[Azure] Building a bot using DLL / WebProject

In previous articles I explained how you can build bots using the Microsoft Bot Framework and the Azure Bot Service. The latter is built on top of Azure Functions, one of my favorite components in Azure. Both the Functions and Bot teams are releasing stuff in a fast pace, but sometimes this leads towards the two not being 100% in sync with each other. This post addresses one of these issues, namely the Bot Service having old-style templates for new instances.

When you create a new Bot Service instance and download the code, you get a solution with .CSX files. These are used in Azure Functions and they still work great. The issue though is that when you load these in Visual Studio and want to debug your code locally, there’s no IntelliSense to go with them. Althought this is on the teams backlog, it’s not there yet and if you’re a VS dev like I am, you probably can’t live without it šŸ™‚

 

.NET Class library as Function App

Two months ago, Donna Malayeri (who’s doing absolutely awesome work on the Functions team) wrote this postĀ detailing how you can build a web project which uses the local functions runtime to host and debug the code. This brings two great worlds together: it allows you to build code in Visual Studio with all the benefits (Intellisense!) whilst utilizing the func.exe CLI runtime as well.

The post does a very good job at explaining how to set this up, but what if you want this for your Bot Service instances?

 

Converting a Bot Service

To convert your bot service instance to a Web Project, here’s what you need:

  • A web project (well duh…).
  • The CSX files that you want to convert to ‘regular’ C# classes.
  • The function.json file that defines the endpoint for your bot.
  • A appsettings file should you have one. This is typically where your Microosft App ID and password are stored.
  • The project.json file. You don’t really need this, but it’s handy to look up which packages your instance is using.

And here’s the steps:

  • Follow Donna’s post to set-up a new web project.
  • When creating the classes, create one for your dialog and one for your entry point. You can combine them as well of course, but I personally like to separate them. In the example these are namedĀ Dialog.cs andĀ DialogEntryPoint.cs.
  • DialogEntryPoint.cs will contain the contents from the ‘run.csx’ file. This the entry point that’s being called when the user communicates with your bot. It’s referenced inĀ function.json as follows:

    Note the scriptFile and entryPoint settings which point to the output DLL and the class/method which handles the incoming message.
  • Dialog.cs contains your dialog code.
  • Ensure that you set-up the project to load the correct NuGet packages. Normally you will needĀ Microsoft.Bot.Builder.AzureĀ which will include some dependencies. If you include this, ensure the project is set-up to run .NET framework version 4.6 instead of 4.5.

Lastly, you need to configure the start options of the project. This is detailed in Donna’s post as well, but for your reference, below are the settings I used. Note that the location of func.exe might differ based on the installation type you used.

botasweb

With everything configured, running the project should now start your bot in the func.exe runtime and hook up VS at the same time for local debugging! Awesome!

funcrunning

 

Sample @ github

If you’re struggling, I took the liberty of adjusting the sample project from the blog post and making a bot specific one from it. You can use it to see how it has been set-up. Be aware that my sample is based on the LUIS bot service, so it does require a settings file with your specific LUIS keys to actually work. Should you have any questions or remarks; feel free to leave them below!

Check out the code:Ā https://github.com/jsiegmund/BotAsWebProject

[Azure] Cortana skills + LUIS pre-built domains

A while ago I was planning on doing a few posts on bots, but I never really got to that it seems. I did get into the bot building business though, so here’s one about a little bit more advanced use of bots: language understanding. And although I might write “more advanced”, I don’t really mean it. That’s because LUIS makes things so much easier. LUIS? Yeah, that’s short for Language Understanding Intelligence Service. And it’s awesome. (more…)

azure-icon-250x250

[Azure] News for developers, May 2017

This entry is part 1 of 1 in the series Azure news for Developers

Are you having trouble keeping track of everything that’s going around in Azure? You’re not alone! In an effort to do so myself, I’m starting a monthly series called “News for developers” which is exactly that: a summary of all of the Azure flavored news specifically for software developers. Now this is based on my personal feeds and my personal opinion, so you might miss things or see things which in your opinion do not matter. Feel free to leave and comment below and I’ll see what I can do for the next edition. And honestly, this is more a personal reference than anything else so having actual readers would already be awesome šŸ™‚ Enjoy! (more…)

[Azure] WordPress and Azure Redis Cache

I a quest to optimize the performance of my WordPress powered site, I thought I’d give Redis Cache a go. Redis Cache has become the industry default when it comes to caching in a key-value style. Azure has a Redis Cache offering which you can use to enhance the performance of any app. If you’re not familiar with caching: it’s a mechanism to eliminate timely data retrieval actions. Caching can be implemented several different places: you web browser uses caching so that it does not have to retrieve all files on every load. Redis Cache is usually more targeted towards scenario’s like database connections. Instead of getting items from a database table, which usually is relatively slow, you can get them from the cache instead.

 

(more…)

[O365] Adding your chatbot to Skype for Business

Have you been coding your chat bot using the Microsoft Bot Framework? Good news! One of the long awaited features is finally here: the Skype for Business channel! Using this channel, you can now get your but to communicate with users using Skype for Business. This is especially good news for enterprises where S4B is often the primary communication tool. Bots were already available through Microsoft Teams, but not all companies are ready for that yet. Skype was in there as well, but is mostly used on the consumer side. So great to have Skype for Business joining the club!

(more…)

[VS2017] Unable to login “failed to refresh access token”

I was running into this weird error today. For some reason (you know… it happens) Visual Studio lost it’s license. I was still logged in, but requested to re-enter my credentials. So I tried, but I kept getting errors. I then thought: let’s log out and log in again. So yeah, that didn’t happen…

(more…)

[NL] Global Azure Bootcamp @ mStack!

Afgelopen jaar begon ik aan een nieuwe baan. Na 4 jaar werken voor Atos vond ik het tijd voor wat anders. Destijds verruilde ik een werkgever met ongeveer 75 collega’s voor eentje met 75.000 collega’s in 4 jaar tijd groeide dat bedrijf uit naar 100.000 man. Leuke tijd gehad, veel kunnen leren en de mogelijkheid gehad om te werken voor een aantal interessante (en vooral grote) bedrijven zoals DAF, Philips en het ministerie van Buitenlandse Zaken. Toch vond ik het tijd om wat meer focus aan te brengen op technologie die wat mij betreft nog jarenlang een zeer interessante markt zal zijn: Microsoft Azure. En rondom Azure organiseren wij op 22 april (zaterdag) het Global Azure Bootcamp. Gratis!

(more…)

[Azure] Using Azure Functions Proxies

If you’ve started using Functions in Azure and you’ve got multiple set-up by now, you’ll start to find that managing them becomes a bit cumbersome, especially when you’ve spread them across multiple instances. All of the instances will have a different base URL and you might find it difficult to keep naming and versioning in line with what you planned. So now what? Let’s take a look at the newly released Proxies for Azure Functions! (more…)

[Misc] Fixing annoying synchronization problem Outlook Android app

Since my outlook.com instance was upgraded to the ‘new’ experience, I’m having all kinds of issues. Two of the most annoying ones: my rules (junk sweep for instance) are not working. Not at all. Also, the synchronization on my mobile phone was pretty crappy, especially for people / contacts. It would not sync certain contacts (again: not at all) and others it would sometimes sync and sometimes delete. Being a nerd I could not stand this, so I went on to find a fix.

I tried all the logical stuff first: reset the account (which is an option in the app). Switch on / off contact syncing. Remove and add the account. Remove the app and reinstall it. I really tried pretty much everything, nothing worked.

With the update, legacy outlook.com account were moved over to a new infrastructure which is built on Office365 bits and pieces. It’s still Outlook.com, but it looks an awful lot like Outlook Online from Office365 now. And if you know Office365, you also know it’s basically Exchange behind the scenes. (more…)

[Azure] Using precompiled DLL’s for your Functions

One of the cool things about Azure Functions is that they are very easy to get started. You create a new function, type some code and you’re off. This is very nice from a getting started point of view, but once you’re considering to use them for more than just playing around, other things come into play. For instance, you might want to actually test what you’re doing. You might want to reference projects, you might want to reuse some of the code you (or your company) already has. Now there’s all kinds of ways of doing this, but just recently the Function teams introduced another very interesting possibility: the use of precompiled DLL’s. (more…)