With the speed of development in Azure and on the Bot service, all the tutorials I found on this subject are out of date and didn’t take me end to end so I decided to try and write one of my own.
We need to prepare a couple of things before we can actually start building our CI/CD pipeline:
First create Azure DevOps repository where we actually store our code. So head over to your Azure DevOps environment, which will be something like https://dev.azure.com/<project name>/_git/<repo name> and create a new repository.
Then use Git bash to clone the repo to our local disk and initialize the Git repo locally.
git clone https://dev.azure.com/<project name>/_git/<repo name>
After the Git repo is initialized locally, we can now create a new VS bot project in that folder which will allow us to commit and push the code we are building locally to Azure DevOps for further processing. This way, we can develop and test our solution locally and if we say the code shall be deployed to Azure, we can just commit and push and the pipeline will do the rest
First install Visual Studio 2019 community edition from here
Next update it and install the extension for bot building. I chose the Virtual Assistant Template as being the most feature rich and suitable for an enterprise project that I have in mind.
Go to Extensions – Manage Extensions and download the bot template :
Close all VisualStudio windows and installation will start.
When installation is complete, restart Visual Studio and select ‘Create a new project’ with the template that you just installed.
Make sure you create the project in the root folder where you cloned your repo into.
Next you need to build the app to test it before publishing. At this step I got some errors that I was expecting because I had been getting these when I was going through the MS AI-100 course.
And a straightforward update of the SDK from here did the trick
Restarting Visual Studio
Go to File – Open – Project/Solution – select the .sln file for your project from the git directory.
Visual studio will install all the dependencies and load the project. Now when you press build you should get build successful.
Mine is showing an error because there is no Cosmos db set up locally which would normally be used to store state information of the bot when it is deployed in Azure.
The easiest thing to do for testing at this stage is comment out the section where storage is configured:
This allows a running bot when you build it again which can be tested locally in the bot emulator.
The emulator instructions from Microsoft can be found here
Unfortunately when I tested the bot, I was still getting errors that I could see are due to telemetry, which again is a storage problem, ie telemetry not configured with storage.
So I’ll move on from here and finish setting up the development pipeline. First I un-commented the lines I had affected for storage and saved all the project files. Then from Git cmd rand the following.
git add .
git commit -a -m "First commit"
git push origin master
And you should find the files are created in Azure DevOps
Now we need to set up the build pipeline.
Go to Pipeline – Builds – New and select Code in Azure Repos Git
And select the repo just created.
Then the pipeline template. I selected the ASP.NET core (DOT NET Framework)
Review the details then save and run. Enjoy the process of building the pipeline and appreciate it’s complexity:
At this point it is important to note that deployment to Azure has not been configured and we’ll have to come back to that for the task “Azure App Service Deploy”.
So that’s the next thing, to create the release pipeline.
Pipelines – Releases – New Pipeline. Select the “Azure App Service deployment” template.
Add an artifact to the pipeline, which actually the finished “product” from our build pipeline.
So select your project, source (which is our build pipeline) and the version you want to add.
Now add tasks to the stage. This will include creating the Azure resources.
At this stage, am getting a nice big red error message about permissions on the Azure Subscription. And it’s late so part 2 will have to be continued tomorrow night.