Skip to main content

19 posts tagged with "microsoft"

View All Tags

· 8 min read

Back in January, I started building skills for AI coding agents — domain-specific guidance that helps agents like GitHub Copilot, Claude, and others produce better code in areas they'd otherwise struggle with. My domain happened to be Azure Cosmos DB, but the lessons apply to anyone writing skills for any technology.

Six months later, what I learned about how to write for AI agents turned out to be far more interesting than the domain knowledge itself.

· 4 min read

I recently had the incredible opportunity to join Scott Hanselman on the Azure Developers Show to talk about something I've been deeply passionate about — turning coding agents into Azure Cosmos DB experts with the Agent Kit.

This session was special to me, not just because of the topic, but because of the person I got to share the stage with.

· 3 min read

Overview:

As a Developer, If you have a requirement to have list of work items which are approved to be displayed in a Grid View. You would tend to query for all approved work items and display them in the grid, one point to note is that since the amount of approved work items might grow over time, hence loading the data would get slower and slower due to having to download more items. In general, this is where pagination comes into play in front end development, which means you don't need to necessarily download all records, just download a page of records at a time. If you are using Cosmos DB as a backend, this feature is supported out of the box via the use of Continuation Token. Cosmos DB SDKs utilize a continuation strategy when managing the results returned from the queries.

Pagination with @Azure/cosmos SDK:

One of the frequent questions I have come across on forums is on How to Implement Pagination with @azure/cosmos SDK with JavaScript. With this post , I wanted to keep it simple and add a very minimal quick start on how to implementation pagination with .js SDK. You can follow the steps given in the repository.

Prerequisites:

  • Create a CosmosDB Account of type SQL API and database named 'javascript' and collection named 'products'
  • Insert the data 'ProductsData.json' to CosmosDB using the Data Migration Tool

execute.ts is the start point of the application which invokes the CallPagination method defined in the pagination.service.ts.

import dotenv from "dotenv"
import { Helper } from './helper';
import PaginationService from './pagination.service';

dotenv.config()

const cosmosDB = new Helper();
const pageMod = new PaginationService(cosmosDB);


const callPagination = async () => {
const result = await pageMod.executeSample(2, "")
console.log({
data: result.result,
dataLength: result.result.length,
hasMoreResult: result.hasMoreResults,
contToken: result.continuationToken
});
};

callPagination();

Implementation is really simple as we are passing a simple query that has more than 40 records and we set the pageLimit as 5 which is the max number of items to be returned in single call.

 public async executeSample(
pageLimit: number = 5,
contToken: string = ""
): Promise<{
result: Array<any>;
hasMoreResults: boolean;
continuationToken: string;
}> {
const sqlQuery =
`SELECT * from products where products.CategoryName = "Bikes, Road Bikes"`
console.log({ sqlQuery })

const { result, hasMoreResults, continuationToken } =
await this.cosmosHelper.queryContainerNext(
{
query: sqlQuery
},
{
maxItemCount: pageLimit,
continuationToken: contToken
},
process.env.CONTAINER_NAME
);

return {
result: result || [],
hasMoreResults: hasMoreResults || false,
continuationToken: continuationToken || "",
};
}

You can access the whole sample from this link.

Steps to Run the application

  • Clone the Repository
  • Run npm install
  • Replace the environment COSMOS_ENDPOINT,COSMOS_KEY,COSMOS_DATABASE_NAME,CONTAINER_NAME in the .env file
  • Run npm start run the application

Hope this helps someone who wants to implement Pagination with JavaScript. Cheers!

· 3 min read

I was working with a partner recently in developing Apps and integrated them as a part of Teams. At times there are questions from customers whether they would be able to utilize the features of teams within their application. The simple answer for the will be NO as Teams Platform Architecture is enabling developers to bring adoption to teams by building more applications from different industry verticals which can be embedded inside teams

However there are two ways you can make the user to navigate to Microsoft Teams from the web application or even from Outlook.

Make a clickable link for Teams chat :

Here is a handy tip on how to make a one-click link that will open up Teams chat to you or the person who is already logged in. Say if you are using a web application which is on Angular, simply you can add a click event to navigate to teams with the code,

 takeUserToTeams() {
window.location.href='http://teams.microsoft.com/l/chat/0/[email protected]';
}

When the user click on the button it will open a web page where the user will sign-in with their Microsoft account. If the Teams app is installed on the client's computer, the web page will offer to open the chat in the Teams client, otherwise they can use the Teams web browser experience

User Navigation from web app to Teams

Opening chat seamlessly once user login

This is a very simple tip but most of the customers are asking for a way to do the same.

Create a Share to Microsoft Teams

Third-party websites can also use the launcher script to embed Share to Teams buttons on their webpages which will launch the Share to Teams experience in a popup window when clicked. This will allow you to share a link directly to any person or Microsoft Teams channel without switching context.

Step 1: Add  launcher.js script on your webpage.

https://teams.microsoft.com/share/launcher.js

Step 2 : add an HTML element on your webpage with the teams-share-button class attribute and the link to share in the data-href attribute.

<div
class="teams-share-button"
data-href="https://<link-to-be-shared>">
</div>

This will add the Microsoft Teams icon to your website.

Share to Teams icon

That's it whenever user click the button content will be posted on the user directly from your apps to teams.

Hope these 2 tips helps someone out there to integrate teams with your application easily to navigate the users to teams!

· One min read

The online MVP Community Quiz is an online quize program by Isidora Katanic, who is the organizer of the famous community events such as Experts Live Europe and Experts Live Switzerland.

Before joining with Microsoft, I have been a Microsoft MVP continuously for 2 years that gave me the opportunity to meet so many experts across the world and get to know them and the communities. The quiz mainly covered the questions among the interesting facts about famous MVPs and the community events.

🏆 Among the winners!

It's great to be listed among the winners as there were participants from 23 countries around the world.

· 9 min read

Overview

This is my 2nd post about a Chatbot solution to address the world wide problem "CoronaVirus" panademic. As it is now spreading across the world and its really vital to provide all citizens of the countries with up-to-date information. As we know it has come to a level that certain countries are in lockdown mode , more and more people are started to practice social distancing and work from home. As we have seen in the previous blog about the sentiment analysis of employees working form home, in this blog i will explain about how to build a chat bot to provides answers to most of the queries related to health information and latest learning. Chatbot is a platform which can be integrated with Web inteface or any collaboration tools such as MS Teams, Slack or Telegram and it can be operated 24*7 without any downtime.

Prerequisites:

You will need to have an Azure Subscription. If you do not have an Azure subscription you can simply create one with free trial.

How to Build:

If you are new to building Chatbot, it is extremely easy and you can enable access to knowledge base via bot in few minutes.

Step 1: Create the Resource Group

As the first step, we need to create the resource group that contains all the resources needed. Navigate to Azure Portal and create the resource group named “rg-chatbot”

Create Resource Group

Step 2: Create a knowledge base

As the next step, navigate to QnA maker,sign-in with your Microsoft account and then click "Create a knowledge base" option

QnA maker

click "Create a QnA service" button in "Step 1" as shown below;

Create QnA service

You will be re-directed to Azure portal. Fill in the template form, and make sure to set pricing tier for "QnA Maker service" to F0, and for the supporting Azure Search service to F, if you want to host your Bot components for free. Then click "Create" button;

Create QnA service

As you could see in the portal Deployment of the relevant resources in your target resource group. If successful, you should get notification as resources deployed. As you will see the following resources under the particular resource group

Resources in QnA

Click on the App Service Plan you created

Note : By Default when you create, App Service Plan for the website is set to S1 pricing tier. You need to change it to the F1 tier if you don't want to have much cost incur on your subscription. You can do this by navigating to Scale Up(App Service Plan) and then select Dev/Test tab and select F1 and Apply.

Change the AppService plan

Step 3 : Connect your QnA service to your KB.

Navigate to the QnA maker again and click 'Refresh" button in "Step 2"

Click on Refresh and select the bot we created

Give a meaningful name to your Knowledge Base (KB)

Name your KB

Step 4 : Populate Knowledge base from different sources

You can specify different sources to feed your knowledge base. It can be populated uploaded from files (e.g., in PDF, MS Word, MS Excel, etc. formats) or typed manually or from Web sites (containing FAQ). For this example, we will be using the recommended standard Knowledge base with Covid-19 FAQs from the  Centers for Disease Control and Prevention and World Health Organisation Web sites.

Knowledge Base Sources

Also in the next step chit-chat" section you may choose "personality" for your bot, so that it can answer some additional small talk questions. This option will enrich the knowledge base with additional question/answer details, so you bot may respond to various greetings.

Populate KB

Now you can create your KB with a simple button click to setup your knowledge base and populate it with the data from the different configured sources.

Select the way it should answer small-talk questions

Once it successfuly created, you will see a window as follows,

Create the knowledge base

Step 5: Test bot's knowledge base

It's time to test bot'ts knowledge base , by clicking -> Test button, then type a question and enter,

Test Knowledge base

If you are happy with bot's responses, just go ahead and click "Save and train", then switch to "Publish " tab and publish the Knowledge base

Publish the Knowledge base

Step 6: Create Bot

Once it got successfully published, you can click on Create Bot as follows,

Create Bot

You will be re-directed to Azure portal where you can set the pricing tier of your Azure Bot Service to F0 (free one) , and you can pick SDK language as the one you are familiar with (either C# or Node) and the click "Create" button;

Create Web Bot

You can obtain the QnA authKey by clicking on it and from the deployment details,

Obtaining AuthKey

Once we filled everything, just hit Create button. Once it get deployed you will be able to see it from the notification.

Once Web App Bot is deployed , you may verify its functionality by selecting "Test in Web Chat" in the left navigation bar and then typing your messages in the Test window.

Test in Web Chat

If you get replies similar to what is shown on the screenshot above, congratulations - you have successfully completed setup and training of your bot !

Next step would be to make it accessible in your platform of choice.

Step 7 : Embed your bot into any web site of yours

Azure Web App Bot can communicate with external world via so called "channels". The channels are built for the relevant collaborating platforms, e.g. Skype,MS teams or Telegram. To find out more about supported channels, please consult Microsoft documentation here. By default, Web App Bot has "Web Chat" channel activated. It means that you can easily start using it on your Web site.

Navigate to Channels on the blade of created bot, then click "Get bot embedded codes" and finally click "Click here to open Web Chat configuration page" link.

Web Chat

Now click the "Show" link to reveal one of the secret keys. Use it to replace the <YOUR_SECRET_CODE> placeholder in the provided embedded code sample.

You can now paste this embedded code into the source code of your target website.

Now you can embed this into a Web sites can be built using various Web development frameworks: be it Angular,React,Vue,Angular or anything else.

Copy the code and embed in your site

Simply clone the repository, then replace the <PUT_YOUR_SECRET_CODE> placeholder on line 1059 with the secret code from your Web Chat configuration page (as described above).
You will then have a fully functional web page with an embedded QnA chatbot.

In this case, i already have built an Covid Tracker application with Angular and this how it looks when i embed the code what we got from the portal.

Covid tracker with BOT in place

Step 8: Enable Chatbot in Microsoft Teams

Say if you want to serve internal audience such as employees and if you are widely using Microsoft Teams in this crisis situation, you would nee to activate relvant channel in the bot's configuration.

Open Web App bot resource in the Azure portal again and select "Channels" option from the blade and click Microsoft Teams icon and press Save button

Select the channel you want to integrate with

Once it got successfully published, you can navigate to Channels blade again and see the Microsoft Teams channel in running state.

MS teams on running state

Now, switch to Microsoft Teams client, select "App Studio" from the left navigation bar if you dont have App studio, just install it from here

Click "Manifest Editor" tab and then click "Create a new app" button. 

Create a new App on teams

Fill all the details which are necessary and mandatory,

Add the details and make sure you get through all validation

Next in Capabilities -> Bots" choose your Azure bot from "Existing bot" tab's drop-down list and then define its scope in MS Teams, e.g. "Personal" and "Team" for your users to chat with the bot directly and within specific teams.

Setup the bot

Finish -> Test and distribute", use "Install" button (if you have MS Teams administrator access) or "Download" button (to send .ZIP package with the manifest details to your MS Teams administrator) to make your bot available in your MS Teams environment.

We're adone

If successful, then you should be able to chat now with your bot directly from within MS Teams.

BOT in Lit Mode

The above can be integrated into any social media platform listed in the channels and its quite easy

You can also consider using HealthCare Bot if you are focused to have the chatbot to handle related scenario only and he is a detailed article on how to build the same.

Things to add/Improve:

Modify your bot with lot more cool features with images and more content via the code (either c#/Node)

Keep the knowledge base upto date : As shown aove it is important to keep your bot's knowledge base up to date. You can just navigate to the QnA maker website and click on Save and Train button and publish as we shown above.

I am sure this would be useful to those who have built COVID trackers , you can just create and embed this chat bot within your web application, and for others to support employees who are working from home you can extend this bot on the respective collaboration tool. Let's fight against COVID with these cool technology and make this world a better place. Cheers!

· 3 min read

In general, any certification offers practical experience to individuals from all the aspects to be a proficient worker.Certified professionals have more beneficial and relevant networks that help them in setting career goals for themselves.Since last year I concentrated on the different Azure certifications. This year I have have a target to complete certifications on different areas too. As a start for this year, i did the certification PL-900 today and i would say it is one of the easiest exam if you have prior experience in building Mobile applications and have a general idea on how to solve business problems.

Microsoft's Power Platform

Microsoft's Power Platform is a low code platform (an environment with graphical user interfaces rather than traditional scripts and programming languages) powered by Microsoft Azure (the cloud computing platform) enabling organisations to analyse data from multiple sources, act on it through created applications and automate business processes.he Power Platform contains 3 key aspects (Power Apps, Power BI,Power Virtual Agents, and Power Automate) and integrates with 2 main ecosystems (Office 365 and Dynamics 365).

PL-900: Microsoft Power Platform Fundamentals

Last year November the new PL-900: Microsoft Power Platform Fundamentals was released in Beta mode and it's recently went into generally available.

After reading the "Skills Measured" section, I realized that a lot of what I have implemented in the past as a developer and i had some experience with PowerBI as well.

Based on the content , i was confident enough to take the exam but I wanted to make sure I was completely prepared for the exam on the topics which i am not familiar with, so did some learning on Dynamics 365 on Microsoft Learn and the Common Data Service (CDS) on Microsoft Learn as well.

Exam Materials and Tips:

You need to only spent 3-4 hours reviewing the Learning Path of Power Platform Fundamentals if you are already familiar with the topics. It's a pretty straight forward exam for which if you read the course on Microsoft Learn, you should be good to go. If you are aware of all the components of the Power Platform, you probably can give the exam as is.

Link to Exam: Here
Released: 4th November 2019 (GA 18/02/2020)
MS Learn: Modules available

I would request anyone preparing for PL-900 to have a good grasp of the following subjects:

  • Common Data Service
  • Difference between Power BI Desktop and Power BI Service
  • Power Apps Portals
  • AI Builder Models
  • Difference between Business Rules and Business Process Flows
  • How Power Platform works with Dynamics 365

It is not a hard exam if you are from the developer background, however get well prepared for this one! As always get hands on. Let’s be citizen developers together. Cheers!

· 6 min read

Microsoft's Power Platform is a low code platform which enable the organization to analyse data from multiple sources, act on it through application and automate business process. Power Platform contains 3 main aspects (Power Apps,Power BI and Microsoft Flow) and it also integrates two main ecosystems(Office 365 and Dynamics 365). In this blog we will see in detail about Power Apps which helps to quickly build apps that connects data and run on web and mobile devices.

Overview :

We wills see how to build a simple Power App to automate scaling of resources in Azure in a simple yet powerful fashion to help save you money in the cloud using multiple Microsoft tools. In this post, we will use Azure Automation run books to code Azure Power Shell scripts, MS Flow as orchestration tool and MS Power Apps as the simple interface. If you have an Azure Environment with lot of resources it becomes hassle to manage the scaling part of it if you don't have the auto scaling implemented. The following Power App will help to understand how easy it is to build the above scenario.

Prerequisites :

We will use the following Azure resources to showcase how scaling and automation can save lot of cost.

  • AppService Plan
  • Azure SQL database
  • Virtual Machines

Step 1: Create and Update Automation Account :

First we need to create the Azure Automation account. Navigate to Create Resources -> search for Automation Account on the search bar. Create a new resource as follows,

Once you have created the resource, you also need to install the required modules for this particular demo which includes
-AzureRM.Resources
-AzureRM.Profile

Installing necessary Modules

Step 2: Create Azure PowerShell RunBooks

Next step is to create the run books by going to the Runbooks blade, for this tutorial lets create 6 run books one for each resources and its purpose. We need to create PowerShell scripts for each of those types

Scale Up SQL
-Scale Up ASP
-Start VM
-Scale Down SQL
-Scale Down ASP
-Stop VM

Creating RunBook

PowerShell scripts for each of these are found in the Github repository. We need to create runbook for each of the scripts.

All the runbooks above can be scheduled and automated to run for desired length of time, particular days of the week and time frame or continuously with no expiry. For an enterprise for non-production you would want it to scale down end of business hours and at the weekend.

Once we tested with the above Powershell scripts and the runbooks, tested and published now we can move on the next step to create the Flow. Navigate to Flow and Create New App from the template.

New Flow from the template

Select the template as PowerApps Button and the first step we need to add is the automation job. When you search for automation you will see the list of jobs available. Select Create Job and pick the one you created above. If you want to all the actions in one app, you can add one by one, If not you need to create separate flows for each one.

In this one, i have created one with the ScaleUpDB job which will execute the Scale up command of the database.

Once you are done with all the steps save the flow with necessary name.

Once we create PowerApp flow buttons login to MS PowerApps with a work/school account. Navigate to Power Apps which will give a way to create a blank canvas for Mobile or tablet. Next you can then begin to customise the PowerApp with text labels, colour and buttons as below

PowerApps Name

In this case we will have a button to increase/decrease the count of instances of the sql db, my app looked like below with few labels and buttons.

AutoMateApp

Next is to link the flow to the button of the power App by navigating to the Actions -> Power Automate

Linking Button Action

Once both Scale Up/Scale down actions are linked, save the app and publish

Step 5 : Verify Automation

Inorder to verify if things are working correctly, click on scale up and scale down few times and navigate to Azure Portal and open the Automation account we created.

Navigate to the overview tab to see the requests for each job made via the power app as below.

Jobs executed.

In order to look at the history navigate to the Jobs blade

Jobs Execution

further you can build a customized app for different environments with different screens using Power App. With the help of Azure Alert, whenever you get an alert regarding the heavy usages of resources/spikes, with single click of button you will be able scale up and scale down the resources as you need.

Improvements and things to consider:

This is just a starting point to explore more on this functionality, but there are improvements you could add to make this really useful.

(i) Sometimes the azure automation action fails to start the runbook. When you are implementing flow needs to handle this condition.

(ii) Sometimes a runbook action will be successful, but the runbook execution errored. Consider using try/catch blocks in the PowerShell and output the final result as a JSON object that can be parsed and further handled by the flow.

(iii) We should update your code to use the Az modules rather than AzureRM.

Note : The user who executes the PowerApp also needs permission to execute runbooks in the Automation Account.

With this App, It becomes handy for the operations team to manage the portal without logging in. Hope it helps someone out there! Cheers.

· 6 min read

Microsoft's Power Platform is a low code platform which enable the organization to analyse data from multiple sources, act on it through application and automate business process. Power Platform contains 3 main aspects (Power Apps,Power BI and Microsoft Flow) and it also integrates two main ecosystems(Office 365 and Dynamics 365). In this blog we will see in detail about Power Apps which helps to quickly build apps that connects data and run on web and mobile devices.

Overview :

We wills see how to build a simple Power App to automate scaling of resources in Azure in a simple yet powerful fashion to help save you money in the cloud using multiple Microsoft tools. In this post, we will use Azure Automation run books to code Azure Power Shell scripts, MS Flow as orchestration tool and MS Power Apps as the simple interface. If you have an Azure Environment with lot of resources it becomes hassle to manage the scaling part of it if you don't have the auto scaling implemented. The following Power App will help to understand how easy it is to build the above scenario.

Prerequisites :

We will use the following Azure resources to showcase how scaling and automation can save lot of cost.

  • AppService Plan
  • Azure SQL database
  • Virtual Machines

Step 1: Create and Update Automation Account :

First we need to create the Azure Automation account. Navigate to Create Resources -> search for Automation Account on the search bar. Create a new resource as follows,

Once you have created the resource, you also need to install the required modules for this particular demo which includes
-AzureRM.Resources
-AzureRM.Profile

Installing necessary Modules

Step 2: Create Azure PowerShell RunBooks

Next step is to create the run books by going to the Runbooks blade, for this tutorial lets create 6 run books one for each resources and its purpose. We need to create PowerShell scripts for each of those types

Scale Up SQL
-Scale Up ASP
-Start VM
-Scale Down SQL
-Scale Down ASP
-Stop VM

Creating RunBook

PowerShell scripts for each of these are found in the Github repository. We need to create runbook for each of the scripts.

All the runbooks above can be scheduled and automated to run for desired length of time, particular days of the week and time frame or continuously with no expiry. For an enterprise for non-production you would want it to scale down end of business hours and at the weekend.

Once we tested with the above Powershell scripts and the runbooks, tested and published now we can move on the next step to create the Flow. Navigate to Flow and Create New App from the template.

New Flow from the template

Select the template as PowerApps Button and the first step we need to add is the automation job. When you search for automation you will see the list of jobs available. Select Create Job and pick the one you created above. If you want to all the actions in one app, you can add one by one, If not you need to create separate flows for each one.

In this one, i have created one with the ScaleUpDB job which will execute the Scale up command of the database.

Once you are done with all the steps save the flow with necessary name.

Once we create PowerApp flow buttons login to MS PowerApps with a work/school account. Navigate to Power Apps which will give a way to create a blank canvas for Mobile or tablet. Next you can then begin to customise the PowerApp with text labels, colour and buttons as below

PowerApps Name

In this case we will have a button to increase/decrease the count of instances of the sql db, my app looked like below with few labels and buttons.

AutoMateApp

Next is to link the flow to the button of the power App by navigating to the Actions -> Power Automate

Linking Button Action

Once both Scale Up/Scale down actions are linked, save the app and publish

Step 5 : Verify Automation

Inorder to verify if things are working correctly, click on scale up and scale down few times and navigate to Azure Portal and open the Automation account we created.

Navigate to the overview tab to see the requests for each job made via the power app as below.

Jobs executed.

In order to look at the history navigate to the Jobs blade

Jobs Execution

further you can build a customized app for different environments with different screens using Power App. With the help of Azure Alert, whenever you get an alert regarding the heavy usages of resources/spikes, with single click of button you will be able scale up and scale down the resources as you need.

Improvements and things to consider:

This is just a starting point to explore more on this functionality, but there are improvements you could add to make this really useful.

(i) Sometimes the azure automation action fails to start the runbook. When you are implementing flow needs to handle this condition.

(ii) Sometimes a runbook action will be successful, but the runbook execution errored. Consider using try/catch blocks in the PowerShell and output the final result as a JSON object that can be parsed and further handled by the flow.

(iii) We should update your code to use the Az modules rather than AzureRM.

Note : The user who executes the PowerApp also needs permission to execute runbooks in the Automation Account.

With this App, It becomes handy for the operations team to manage the portal without logging in. Hope it helps someone out there! Cheers.

· 8 min read

A programmer can code for days continously without a break. I have done it when I started my career as a programmer. In IT field, it gets worse if you continously work without taking 5 minutes break every 30 minutes. In this blog I will explain how you can find yourself to remind someone to get up and take that mandatory break.

PreRequisites:

Sign up Twilio

In order to yse Twilio, you need to sign up and purchase a voice enabled phone number. If you’re new user to Twilio, you can start with a free trial.

Sign up Azure:

In order to deploy your Azure function, you need to have Azure subscription. You can create a FREE Azure subscription to setup your Azure function. The free trial will provide you with 12 months of free services.

Steps to Create the Function:

Step 1 : Create the Function app

Let's start off by creating an app for our requirement. In the Azure portal, click + Create a Resource

When the Azure Marketplace  appears and in the list, click Compute. In the Featured list, click Function App (note: if Function App does not appear, then click See all).

Then you need to fill the function app settings, you can follow the image to setup your funciton,

Step 2 : Add Function

We just completed creating the function app and we need to add a function that provides the capability of alerting the user that is configured with a trigger. The trigger will start the function which sends the Twilio SMS message. We’ll be using a Timer trigger for this tutorial.

In the left menu, click Resource groups and select the resource group you created in the last step.

Click on the App Service which is highlighted. Once the page loads, click the + button next to Functions to create a new function.

Add a Function

On the next screen, you’ll need to choose a development environment. Since we’ll be creating the function in the Azure Portal, select In-Portal and Continue.

Select In Portal

Since we want to create a Timer trigger, you’ll need to select Timer and click Create.

You should now see TimerTrigger1 listed under Functions in the left menu.

Step 3 : Integrate with Twilio SMS

As the next step we need to integrate Twilio SMS with the function App we created. Under TimerTrigger1 click Integrate

Integrate Function

under Outputs, click + New Output and select Twilio SMS.

When you click on that, you will get a warning saying Extensions not installed. You’ll need to install the Mirosoft.Azure.WebJobs.Extensions.Twilio extension. You can do so by clicking Install. This process can take up to 20 minutes so just give it a moment to complete installation.

While the function extensions are getting installed, you need to update the values in the relevant fields, the values can be obtained from your Twilio dashboard as shown below,

and fill them in the environment variables after you installed the extension, you need to set the environment variables which will be used within the function.

Step 4: Set Environment variables

It's ok to hardcode the Twilio credentials in the output environment variables. However, if you are running this app in production you should always use environment variables so that you dont expose the credentials to others. As you obtained the values from the Twilio dashboard, copy and save those values,

You can create environment variables in the Azure Portal by going to the Overview tab for your function and click Configuration.

Add the environment variables one by one,

KeyValue
TWILIO_SIDACXXXXXXXXXXX
TWILIO_TOKENAuth token obtained from the Twilio dashboard
SENDER_NUMBERYour twilio number +94 77 330 XXXXX
RECIPIENT_NUMBERPhone number that recieves the message

Environment variables

You can create the first envrionment variable by clicking on the New Application Setting and repeat the same for rest of those variables as shown above,

New appsettings Configuration

Add the first setting TWILIO_SID

TWILIO_SID Environment Variable

Once you are done with each setting value click OK. When you are adding both SENDER_NUMBER and RECIPIENT_NUMBER be extra careful as it can be tricky and make sure to use the E.164 format referenced above. After all environment variables have been added click Save to save the updates that were made to the Application Settings.

Step 5 : Timer settings

Whenever you create a timer function, By default, Azure sets your function to trigger the text message every 5 minutes. You can change how frequent the timer triggers by going to the Integrate and updating the values in Timer trigger.

Goto your function and select on Integrate and then you need to update the value of the interval as you need. The Schedule field contains a sequence that using CRON expressions. For the purpose of testing the function, change the number 5 to the number 2 and click Save. You can later change the frequency after you confirm that the function works properly.

CRON Expression

If you're creating the Function App using Visual Studio code, follow this sample app to create a timer function which is more easier with Visual Studio Code.

Step 6: Modify function.json File

As we are done with all the configuration steps, now we need to update the function.json within our TimerTrigger1 function.  Go back over to the function app and click TimerTrigger1. On the far-right side of the screen, click View Files.

You will see two files:

  • function.json
  • index.js

Click function.json to open the file. Since the file is currently missing the “to”: “RECIPIENT_NUMBER”, we’ll need to add this to our file.

Now we need to add the logic to create the message and send the message using the Twilio to the relevant reciever.

Navigate to my Github repo and grab the code for this file. You’ll want to replace the existing code in the function.json file with the new code that you just copied from GitHub.

{
"bindings": [
{
"name": "myTimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */2 * * * *"
},
{
"type": "twilioSms",
"name": "message",
"accountSidSetting": "REPLACE_WITH_YOUR_ACCOUNT_SID",
"authTokenSetting": "REPLACE_WITH_YOUR_AUTH_TOKEN",
"from": "SENDER_NUMBER",
"to": "RECIPIENT_NUMBER",
"direction": "out"
}
]
}

Step 7 : Let's Add logic to the index.js file

When Azure creates a function, it adds default code to help setup your function. We will the code for the Twilio SMS message to this code.

In the View Files menu, click the index.js file. You’ll want to replace the existing code in the index.js file with the code below.

const twiAccountSid = process.env.TWILIO_SID;
const twiAuthToken = process.env.TWILIO_TOKEN;
const client = require('twilio')(twiAccountSid, twiAuthToken);
module.exports = async function (context, myTimer) {
var timeStamp = new Date().toISOString();
if (myTimer.IsPastDue)
{
context.log('JavaScript is running late!');
}
client.messages
.create({ from: process.env.SENDER_NUMBER,
body: "Time to have cofee and take a break for 5 minutes!",
to: process.env.RECIPIENT_NUMBER
})
.then(message => {
context.log("Message sent");
context.res = {
body: 'Text successfully sent'
};
context.log('JavaScript timer trigger done!', timeStamp);
context.done();
}).catch(err => {
context.log.error("Twilio Error: " + err.message + " -- " + err.code);
context.res = {
status: 500,
body: `Twilio Error Message: ${err.message}\nTwilio Error code: ${err.code}`
};
context.done();
});
}

Step 8 : Install the dependencies (Twilio)

As you can see the first line of the code is required to use twilio helper library. We’ll need to install the twilio-node from npm so that it’s available to our function. To do so, we’ll need to first add a new file to our function.

Add package.json file

In the View Files window, click Add. Type the file name package.json and click enter. You will see an empty content page in the middle of the screen.

Add Package.json

Add the code below to the package.json file.

{
"name": "doc247",
"version": "1.0.0",
"description": "Alert an employee with an SMS to take a break",
"main": "index.js",
"scripts": {
"test": "echo \"No tests yet...\""
},
"author": "Sajeetharan",
"dependencies": {},
"devDependencies": {
"twilio": "^3.0.0"
}
}

Now we have added Twilio as a dependency to the package.json file , as the next step we need to install it as a dependency on the environment itself. As you are aware you can install the dependencies using the deploy command as well as you can install it using the Kudu.

Note : Make sure to stop the Function app before you head over to Kudu.

Click on the Platform Features tab. Under Development Tools, click Advanced tools (Kudu). Kudu will open on it’s own in a new window.

Navigate to Kudu from the function app

In the top menu of the Kudu Console, click Debug Console and select CMD

Kudu Debug Console

In the command prompt, we’ll want to navigate to D:\home\site\wwwroot. You can do so by using the command cd site\wwwroot and press enter on your keyboard. Once you’re in wwwroot, run the command npm i twilio to install the package.

Install Dependencies Twilio

You will also notice a new node_modules folder added to the file structure. Back in the Overview tab for the function app, click Start.

node_modules Folder

Step 9 : Run and Test the Function

Back in the Overview tab for the function app, click Start. App and click TimerTrigger1. Make sure that you’re in the index.js file. Click Test next to View Files (far right-side of the screen). At the top of the index.js file, click Run

If everything was successful, the personshould receive a text message after 20 minutes with your message!

You can change the frequency for your timer by heading back to Integrate and changing the Schedule field. Be sure to read up on CRON expressions before entering a new frequency.

If you’re curious to learn more about Azure Functions, I would suggest taking this Microsoft Learn module. You can access complete source code from here. If you want to learn more on Azure visit http://azure360.info/ .Happy Coding!

· 3 min read

This week I participated my first ever OpenHack on DevOps organized by Microsoft in Singapore. It was a three day event from 26th-29th November 2019. The hackathon was focused on Azure DevOps and Azure Kubernetes services. There were participants from all over the world gathered at one place.

There were over 90+ Participants comprised of internal employees as well as customers. Participants were divided into 6 members per team with one coach. The content was set as 8 challenges. Coach from each team was some Cloud Solution Architect from Microsoft who was helping and guiding the team during the challenges with some hints to solve it. One of the cool thing of the hack was that each team could apply their own solutions in unique ways. We as a team were supposed to find our way out to solve the challenges. There was no one way, we were free to take our decisions and paths as deemed fit. If you are wondering about the agenda and what happened in the hack, here you go.

My Team RockStars - Announced as Happiest team among all

What I really liked about the openhack was that each team member was really able to understand what's the challenge and was able to get the team's support whenever they're stuck. Before we start each challenge, one member from the team was assigned as a Scrum Master and he has to drive the entire team to complete the challgne. In each challenge, one has to elloborate the feature of whatever the tools/technologies that we would use in the challenge. There was whiteboarding session included in each challenge before we get in to try to solve the challenge. It was a hands-on rather than attending any tech talk about a specific topic. The tasks were set, challenges were well organized, the environment was prepared, code was almost prepared (with some changes) so that we can focus on learning how we can use Azure DevOps as a tool to ensure zero down-time for production ready application. Kubernetes was chosen as an orchestration framework. Azure monitor was used as the Monitoring service.

Microsoft OpenHack is a developer focused event where a wide variety of participants (Open) learn through hands-on experimentation (Hack) using challenges based on real world customer engagements designed to mimic the developer journey.

For every challenge the links to documentation and resources were provided to understand relevant topics and areas at hand. Besides the actual work, it was a great opportunity to network and discuss broader topics with fellow team members and other participants. It was not just about solving challenges, but each one was appreciating others work whenever we accompolished something. we were given with some cool swags including stickers,notebook wireless charger and Azure Devops badge.

There was not a real winner(team) out of this openhack, all the teams who participated thoroughly enjoyed and it was about sharing and solving real issues.Overall, I think it was a great learning experience for all the participants with great focus on getting things done. I will definitely keep an eye on such events in the future and try to join as a Devops coach for the upcoming events. More than the hackathon it was not just about technology but about teamwork. If you want to have the same experience try to join any of the OpenHacks from here.

· 2 min read

One of the cool feature that Microsoft teams provide is that you can load any website as a tab on particular channel. One handy thing i noticed is that if you want to access azure cloud shell in teams you can just add it as a separate tab and manage the resources without navigating to the browser. With simple step you can access your azure portal as a tab in your teams.

Step 1 : Goto your channel on teams and click on + (Add tab)

it will open up a window.

Step 2 : Just type website in the search tab and you should be able to add a new website as a tab.

Step 3: Just add http://shell.azure.com as a website tab and thats it. Now you should be able to execute all the commands without opening up a shell.

You can do the same with most of the frequently accessed websites if you want to demonstrate something while you are on teams. I have done with Stackoverflow and it's really helfpul while github can be added as a separate tab from the available list.

Try it out today, eventhough it is not helpful as the page refreshes when you move to another tab and come back, but really a good feature to have as a developer. Here is a small gif demonstrating how effectively you can navigate between those tabs.

Microsoft teams is getting better with much features day by day!

· 2 min read

There are few mandatory sites that every developer on azure should know. This post will contain a curated list of awesome websites which will definitely help.

Azure Checklist - This checklist is your guide to the best practices for deploying secure, scalable, and highly available infrastructure in Azure

Devops Generator - It is really a nice tool to get you a starting point for your demos on azure devops

Azure Charts - Azure heatmap where you can see the changes to Microsoft cloud services in a heat map visualisation

Cosmic notes - Learn more about Azure Cosmos DB database, one Cosmic Note at a time!

AKS Workshop - You’ll go through tasks that will help you master the basic and more advanced topics required to deploy a multi-container application to Kubernetes on Azure

Price Calulator - Pricing calculator to help you understand the pricing. This tool will make it easier to understand the pricing of the different services/products.

Azure VM pricing - Find and compare Azure Virtual machines specs and pricing on a one page.

Azure IoT Developer Kit - The Microsoft Azure MXChip IoT Developer Kit (a.k.a DevKit) can be used to develop and prototype IoT solutions leveraging Microsoft Azure services. It includes an Arduino compatible board with rich peripherals and sensors, an open-source board package and a growing projects catalog.

Severless Library - Collection of azure functions xamples. If you are looking for some ideas on how Azure functions can be leveraged or need an example for your scenario this is a great resource.

Azure speed test - Use this tool to measure the latency from your web browser to the Blob Storage Service in each of the Microsoft Azure Data Centers.

App Migration - Assess any app with an endpoint scan. Download the Migration Assistant and start your .NET and PHP app migration to Azure App Service.

The above tools/sites have helped me a lot in the journey of myself as a Azure developer. I'm sure this would help any of the developer who wants to get started on Azure.

· 3 min read

Hey NG folks, ng-Srilanka 2019, the First-ever Angular conference on the 14th of September 2019 was a great success. It was a dream come true moment for me. Yes, I am one of those developers who marries one platform or framework and doesn’t care too much about the other ones. I have been an Angularjs/Angular developer for the past 7 years. One of the reasons why I wanted to make this happen was because of the strong and wide Angular community in Sri Lanka. When I became a GDE in Angular in 2018, my first aim was to build a strong developer,especially Angular community in SriLanka. NG-Srilanka has been a 2 year dream and finally I am glad it happened with all grandeur .

To those who missed the event this year, below are some of the biggest highlights and benefits that ng-Srilanka had to offer that you can take right back to your development desk.

First ever Angular conference:

It was such an honor for me and my team to organize this fantastic conference for the first time in SriLanka and 2nd Angular conference in SouthEast Asia. When we started it we never imagined NG-Srilanka will grow into a large international conference which will attract such a strong support from the industry.

For the community, by the community:

A set of volunteers from the two top universities in SriLanka focused on reaching out to and building interest in the local community. The event was adorned by 400+ passionate developers from 15+ universities and 20+ companies. We ensured that we had a diverse speaker line up and further promoted diversity with scholarships and ensured that most participants made it to the event.

NG-Scholarship for students :

Unlike most of the Angular conferences, we came up with a scholarship program to provide free training on Angular by the local experts. The scholarship winners were selected based on the knowledge on Angular and their passion to learn more.

Great Agenda:

NG-Sri Lanka 2019 kicked off with @mgechev of the Angular team, who joined us from California and delivered the keynote. Later, the sessions were divided into two tracks named "Stacked" and "Sandwich". "Stacked" track touched upon various topics on Angular and "Sandwich track" deep dived into specific workshops. The event was also garnsihed with few lighter moments like entertainment performances by NSBM students.

Finally the speakers addressed the audience in an open QnA session, through which certain Angular topics were further discussed.This was a huge value add for the attendees, and proved truly a platform where many meaningful conversations can happen.

An AWESOME Team:

The real success of ng-Srilanka was the team behind it. Thank you, to the fantastic co-organizers who worked with me day and night, the amazing support staff , dedicated volunteers, the sponsors, the awesome speakers and of course the great attendees.I would like to thank everyone who contributed to the success of the event, devoted their time and support to make this conference a big HIT.

Such a nerve wracking but amazing experience! So lucky to work with such a supportive team.

We've been recieving wonderful feedback from the speakers,attendees and several others on social media about the conference. Looking forward to NG-Srilanka 2020!

· One min read

There are few cool speed test tools available out there which allows you to test network latencies and speed to data centers from different countries and locations.  Along with finding the closest Datacenter near your location, it tests the storage latency as well as upload and download speeds. 

Check it out from the following urls:

𝗔𝘇𝘂𝗿𝗲: http://azurespeedtest.azurewebsites.net

𝗔𝗪𝗦: https://cloudharmony.com/speedtest-for-aws

Make use of the above tools to identify which region is suitable for your solution. Hope it helps.

· 2 min read

I have been working with couple of applications built with CosmosDB and one of the things that surprised me was one cannot clear all documents in a collection from the Azure web portal or using the Storage Explorer. As I was struggling to do this while doing some tests on the application I decided to write a blog on the solution I used. There are two ways to achieve the same

  • Using a stored procedure
  • Using Cosmosdb SDK

Using Cosmosdb SDK:

I came up with a script in Node which can be done with any of the programming languages such as C#,Python supported by the SDK

Let’s go through the steps:

Step 1:

Open VScode and Create a file named cosmosdb_helper.js

Step 2:

Let’s install the necessary packages needed.

Install documentdb javascript sdk with the following command,

npm i documentdb

and you will see the output as follows

2019-02-04_21-36-10

Let’s install require to handle the dependencies with the following command,

npm i require

and you will see the output as follows,

2019-02-04_21-36-31

Step 3: 

Let's do some coding. You will be able to understand the following code with the comments added on each line,

https://gist.github.com/sajeetharan/8efe2c9424dfc89d1f58b34627858944

Suppose if you have partitionKey created with your collection, you need to pass queryoptions with the partitionKey in selectAll as well as deletDocument as follows,

https://gist.github.com/sajeetharan/d5302257d3b5e54a33e5601b215decf1

Step 4:

Let’s run the script and see the output,

You can run the helper script as follows,

if you want to list all documents in the collection,

node cosmosdb_helper.js selectAll

which will list the output of all documents in the collection.

If you want to delete all documents within a collection, you can run the script as,

node cosmosdb_helper.js deletAll

which will remove all documents in the collection.

Using a stored procedure:

As mentioned above, 2nd way is to use the stored procecure given by Microsoft employee as mentioned here.

Hope the helper script will help someout out there in order to delete all documents in a collection. You can get the whole code from Cosmosd_Helper

· 2 min read

In this blog i will start with an introduction to .NET Core CLI tools with an example of how to create a web API using the CLI tools provided with .NET Core. At the end we will set up a solution grouping an API project and a test project. Let's dive into the steps,

Step 1 :  Installing the tools

Need to install .NET Core and Visual Studio Code that are supported on Mac, Unix and Windows. You can read more on how it works on multi-platform/framework.

Step 2 :  Creating the solution

Let's open the terminal/Powershell as a administrator to create our solution. Lets create a solution named DotNetCoreDemoApi

  dotnet new sln -o DotNetCoreDemoApi  

The above command will create a new folder and DotNetCoreDemoApi a solution file with the  name DotNetCoreDemoApi sln .

Lets get into that folder.

Step 3: Creating the web API project

Run the following command,

 cd DotNetCoreDemoApi 

Now that the solution is here, we can create our API project. Lets name the web API as DotNetCoreDemoApi. Run the following command to create the project.

dotnet new webapi -o DotNetCoreDemoApi  

That command will create a sub folder named DotNetCoreDemoApi  inside the solution DotNetCoreDemoApi and the ouput is as follows.

The web API folder should contain a few files generated as above  but what we require right now is DotNetCoreDemoApi.csproj. We will add a reference to it in our solution. To do so, run the following command:

 dotnet sln add ./DotNetCoreDemoApi/DotNetCoreDemoApi.csproj

 

 

Step 4: Run the Web API After getting a confirmation message as above , lets start the API by running that command:

 dotnet run --project DotNetCoreDemoApi  

 

After a few seconds, it should display a message  that the API is now running locally as above. You may access it at http://localhost:5000/api/values which is the Values API default endpoint.

That's all , API is ready and it is up and running locally. I will continue setting up the TestProject in the same solution in the upcoming blog. With the DotNet core it is very feasible to get your web api setup and running in 5 minutes.

· 4 min read

This is my first blog and Azure and i am inspired to write this one after attending the Microsoft's workshop "App innovation day".There was a cool technology "Windows Workflow Foundation" provided by Microsoft with dot net framework to create workflows to cater business logic in dot net applications. With Azure, The Logic Apps service fulfill the purpose to have business processes or workflows take shape of an app.

It required no coding just simple logic that needs to placed in a right way to have right business flow. It was also meant for the purpose of integrating 3rd party apps like Facebook,YouTube, Twitter and Evernote etc. All we need to have is the dynamic work flow.There are different benefits and different use cases in which we can apply azure logic apps. Let's discuss some of the benefits when using logic apps!

Rapid development

Logic Apps is great for rapid development.With ever growing list of connectors, we can easily create a workflow to monitor invoice, send for approval to a admin, upload to dropbox and send email notification in matter of few seconds.

Solutions with Hybrid cloud

5 years back ,Lot of businesses have invested heavily in on premises solutions and hardware, so it’s not possible to move everything to the cloud. With Logic Apps, it’s easy to have a hybrid cloud during this transition. With its on premises data gateway, you can easily connect your on premises database, file share, BizTalk server to Azure cloud.

It is the new way of Automating business process. You can build long running business process, that orchestrate data and services across all cloud services and not just Azure. It's not only for the developers but for everyone. The best bit you need to write code , you can use Visual editor to build your orchestration.

Lets Dive into Simple Demo Use Case: Filter twitter feeds with specific hashtags and post the specific tweets on the Facebook wall. In this example , i just created a process that repeats every few minutes to pull some data from twitter feed and post it on your Facebook wall. Even though this feature is already supported with Facebook, here its slightly different since it is filtering only the specific keywords which is a custom filtering.

The entire flow i described about is composted of 3 simple steps , that you can build using a Visual UI.

Step 1: Select Logic App click "Create" and give a specific name ,resource 

 

 Step 2: There are number of workflow templates will be shown as below and select the appropriate one , in this case i will use "when a new tweet is posted"

also authorize with your twitter account from which you want to fetch the feeds

Also configure the conditions by mentioning the filters and the timeline you want to trigger the action.

 

Step 3: Next step is to post on facebook wall , click "Add step"  

Search for Facebook and authenticate will your Facebook account as follows,

Click post to my timeline

Also you can map the fields that you want to fetch from the feed and post it on the wall as below,

 

That's it folks, once all fields are mapped you need to save the Logic app with the save button.

With the above 3 steps posting a filtered tweet on Facebook wall is configured and can be scheduled as you need. If the above particular feature needs to be developed without azure means it will need a huge development time and cost, which can be avoided using the Logic app as shown above.

That's the demo. You can explore several steps and several templates provided in the portal without writing a single line of code. I will be writing a separate blog on how to configure custom logic app in the upcoming blog posts. Happy connecting with app logic!