Skip to main content

· 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!

· One min read

If you have been using Azure already or new to Azure, you must know that Microsoft Azure is huge and it changes very fast with new services and updates. It can be really overwhelming to see the new releases,features at the same time it is very hard to know which services to use for the given scenario of your application.

I have been working with few customers and partners and i have a method that i use to help me to pick the right compute service on azure. This helps me to narrow down the services to choose from and pick the right one for the solution. The following decision tree helps you to decide which service to pick

Azure Decision Tree

I also have implemented a visulization to depict the above picture using a tool which you can access from Azure360.

Have fun and pick the right service to build your next solution.

· 4 min read

You might have noticed my recent posts were mostly focused on how to get started and learn Azure in 2020. This post is also to help all Azure enthusiasts to get to know and download all the free ebooks by Microsoft to learn more in depth about Azure. I have added the reference to this blog in my tool Azure 360 as well. There are around 174 ebooks which can be downloadable from the Microsoft site as of now. I have listed the top 60 books which are recommended and liked,shared the most among the social mediums.

Ebooks For Achitects,Developers and Decision Makers

eBook NameDownload
Azure for ArchitectsPDF
Designing Distributed SystemsPDF
Cloud Migration EssentialsPDF
Kubernetes : Up and RunningPDF
Learning Azure Cognitive ServicesPDF
Effective DevOps—Building a DevOps Culture at ScalePDF
How to Containerize Your Go CodePDF
Build and deploy a multi-container application in Azure Container ServicePDF
Build and deploy multi-container application in Azure Service FabricPDF
Kubernetes objects on Microsoft AzurePDF
Azure Serverless Computing CookbookPDF
Create your first intelligent bot with Microsoft AIPDF
Best Practices for Migrating Windows Servers to AzurePDF
Cloud Database Migration EssentialsPDF
Getting started with Apache Spark on Azure DatabricksPDF
15 Lessons Learned: Migrating SAP to the CloudPDF
Learning Node.js Development and deploy on AzurePDF
Cloud Analytics with Microsoft AzurePDF
Grow Your ISV Business with SaaSPDF
Building Intelligent Cloud ApplicationsPDF
Manage your network more effectively with the Azure Networking CookbookPDF
Developer’s Guide to Getting Started with Microsoft Azure Database for MySQLPDF
Developer's Guide to Getting Started with Cosmos DBPDF
Quick Start Guide to Azure SentinelPDF
The Developer's Guide to AzurePDF
Kubernetes on AzurePDF
Professional Azure SQL Database AdministrationPDF
Devops with ASP.NET Core and AzurePDF
Devops for Containerized AppsPDF
Enterprise Cloud StrategyPDF
Implementing a Zero Trust approach with Azure Active Directory PDF
Microsoft Azure Trips and Tips - DataPDF
Azure AD Application Proxy – Adoption Kit – eBookPDF
Azure Active Directory B2B Collaboration – Adoption Kit – eBookPDF
AI for Retail: Learn the scenarios that are driving today's digital consumerPDF
Building IoT Solutions with Azure: A Developer’s GuidePDF
The enterprise developer’s guide to building five-star mobile appsPDF
Modernizing existing .NET appsPDF
Azure Active Directory Company Branding- Adoption Kit – eBookPDF
Azure Migration SQL Server to Azure SQL Database Managed Instance a step by step guidePDF
Azure Active Directory Connect Health- Adoption Kit – eBookPDF
Azure Active Directory Self-Service Group Management – eBookPDF
AI in Action—explore three technical case studies in one guidePDF
Azure Active Directory Identity Protection – eBookPDF
Azure Multi-Factor Authentication – eBookPDF
Azure Privileged Identity Management – eBookPDF
Azure Active Directory Single Sign-On – eBookPDF
Azure Active Directory Self-Service Password Reset – eBookPDF
Azure Active Directory User Provisioning – eBookPDF
Five Principles for Deploying and Managing Linux in The Cloud with AzurePDF
Optimizing Azure Site Recovery (ASR) WAN OptimizersDOC
Azure VM – Oracle 12c on Linux – Configuration Steps – eBookPDF
Azure Strategy and Implementation GuidePDF
Build your first intelligent app with a guide from O’ReillyPDF
Guide to migrate schema & data from Oracle to Azure SQL DBPDF
How to Set up Azure AutomationPDF
Deploy IBM DB2 pureScale on AzurePDF
Azure AD in Windows 10 cloud subscriptionsPDF
Learn Azure in a Month of LunchesPDF
Microsoft Azure Essentials Migrating SQL Server DatabasesPDF
Migrate your SAP estate to the cloud—securely and reliablyPDF
Microsoft Azure ExpressRoute GuidePDF
Making the Most of the Cloud EverywherePDF
APIs + MicroservicesPDF
Hands-On Linux Administration on AzurePDF
Designing your Hybrid Cloud Strategy: Identity and Access ManagementPDF
Overview of Azure Active DirectoryDOC
Containerize Your Apps with Docker and KubernetesPDF
Solve your big data and AI challenges with an Azure Databricks use case e-bookPDF
Azure Rapid Deployment Guide For Azure Rights ManagementPDF
Practical Microsoft Azure IaaSPDF
IoT in the Real World: Stories from ManufacturingPDF
Continuous Delivery in JavaPDF
Azure Rethinking Enterprise Storage: A Hybrid Cloud ModelPDF
Azure AD/Office 365 seamless sign-inDOC
Exam Ref AZ-900 Microsoft Azure Fundamentals (NOT eBook)PDF
Azure AD & Windows 10: Better Together for Work or SchoolDOC

If you want to access all the Ebooks,Research papers, Reports in one place you can directly go here and get it. Hope these links will be helpful and Azure be the cloud you love!

· 4 min read

You might have noticed my recent posts were mostly focused on how to get started and learn Azure in 2020. Want to become more productive with Azure?. There are around 174 ebooks which can be downloadable from the Microsoft site as of now. I have listed the top 60 books which are recommended and liked,shared the most among the social mediums.

eBooks For Architects,Developers and Decision Makers

eBook NameDownload
Azure for ArchitectsPDF
Designing Distributed SystemsPDF
Cloud Migration EssentialsPDF
Kubernetes : Up and RunningPDF
Learning Azure Cognitive ServicesPDF
Effective DevOps—Building a DevOps Culture at ScalePDF
How to Containerize Your Go CodePDF
Build and deploy a multi-container application in Azure Container ServicePDF
Build and deploy multi-container application in Azure Service FabricPDF
Kubernetes objects on Microsoft AzurePDF
Azure Serverless Computing CookbookPDF
Create your first intelligent bot with Microsoft AIPDF
Best Practices for Migrating Windows Servers to AzurePDF
Cloud Database Migration EssentialsPDF
Getting started with Apache Spark on Azure DatabricksPDF
15 Lessons Learned: Migrating SAP to the CloudPDF
Learning Node.js Development and deploy on AzurePDF
Cloud Analytics with Microsoft AzurePDF
Grow Your ISV Business with SaaSPDF
Building Intelligent Cloud ApplicationsPDF
Manage your network more effectively with the Azure Networking CookbookPDF
Developer’s Guide to Getting Started with Microsoft Azure Database for MySQLPDF
Developer's Guide to Getting Started with Cosmos DBPDF
Quick Start Guide to Azure SentinelPDF
The Developer's Guide to AzurePDF
Kubernetes on AzurePDF
Professional Azure SQL Database AdministrationPDF
Devops with ASP.NET Core and AzurePDF
Devops for Containerized AppsPDF
Enterprise Cloud StrategyPDF
Implementing a Zero Trust approach with Azure Active Directory PDF
Microsoft Azure Trips and Tips - DataPDF
Azure AD Application Proxy – Adoption Kit – eBookPDF
Azure Active Directory B2B Collaboration – Adoption Kit – eBookPDF
AI for Retail: Learn the scenarios that are driving today's digital consumerPDF
Building IoT Solutions with Azure: A Developer’s GuidePDF
The enterprise developer’s guide to building five-star mobile appsPDF
Modernizing existing .NET appsPDF
Azure Active Directory Company Branding- Adoption Kit – eBookPDF
Azure Migration SQL Server to Azure SQL Database Managed Instance a step by step guidePDF
Azure Active Directory Connect Health- Adoption Kit – eBookPDF
Azure Active Directory Self-Service Group Management – eBookPDF
AI in Action—explore three technical case studies in one guidePDF
Azure Active Directory Identity Protection – eBookPDF
Azure Multi-Factor Authentication – eBookPDF
Azure Privileged Identity Management – eBookPDF
Azure Active Directory Single Sign-On – eBookPDF
Azure Active Directory Self-Service Password Reset – eBookPDF
Azure Active Directory User Provisioning – eBookPDF
Five Principles for Deploying and Managing Linux in The Cloud with AzurePDF
Optimizing Azure Site Recovery (ASR) WAN OptimizersDOC
Azure VM – Oracle 12c on Linux – Configuration Steps – eBookPDF
Azure Strategy and Implementation GuidePDF
Build your first intelligent app with a guide from O’ReillyPDF
Guide to migrate schema & data from Oracle to Azure SQL DBPDF
How to Set up Azure AutomationPDF
Deploy IBM DB2 pureScale on AzurePDF
Azure AD in Windows 10 cloud subscriptionsPDF
Learn Azure in a Month of LunchesPDF
Microsoft Azure Essentials Migrating SQL Server DatabasesPDF
Migrate your SAP estate to the cloud—securely and reliablyPDF
Microsoft Azure ExpressRoute GuidePDF
Making the Most of the Cloud EverywherePDF
APIs + MicroservicesPDF
Hands-On Linux Administration on AzurePDF
Designing your Hybrid Cloud Strategy: Identity and Access ManagementPDF
Overview of Azure Active DirectoryDOC
Containerize Your Apps with Docker and KubernetesPDF
Solve your big data and AI challenges with an Azure Databricks use case e-bookPDF
Azure Rapid Deployment Guide For Azure Rights ManagementPDF
Practical Microsoft Azure IaaSPDF
IoT in the Real World: Stories from ManufacturingPDF
Continuous Delivery in JavaPDF
Azure Rethinking Enterprise Storage: A Hybrid Cloud ModelPDF
Azure AD/Office 365 seamless sign-inDOC
Exam Ref AZ-900 Microsoft Azure Fundamentals (NOT eBook)PDF
Azure AD & Windows 10: Better Together for Work or SchoolDOC

If you want to access all the EBooks,Research papers, Reports in one place you can directly go here and get it. Hope these links will be helpful and Azure be the cloud you love!

· 2 min read

What a way to start the new year 2020!. It just began and I am feeling as I've achieved something. It is always great when you are being recognized for your hard work and dedication. A growing list of subscribers and ever increasing traffic stats are pretty awesome! However, for the first time in my career to be ranked among the Microsoft Azure blog to follow in 2020 is truly amazing! Today, Feed spot published their list of the Top 50 Microsoft Azure Blogs to follow in 2020 and i was surprised to see my name in the spot number #27.

While i am honored to be in that list, I would recommend and it’s also important to note all the other great blogs on the list too. Take a moment to check out the list and browse through all the other great blogs on the Top 50 list as well. Congratulations everyone, the azure community wouldn’t be what it is without each of you; in addition to the countless other blogs that didn’t make the list.

"If you have knowledge, let others light their candle in it"

Thanks Feedspot and everyone for the support ! I’m sure we’ll be seeing each other next year as well.