Going Serverless

Over the last few years as technology has improved and the cloud providers built out more and more infrastructure, serverless began to grow.

Serverless doesn't mean there is no server. What serverless means is that you don't have to worry about the server. The provider does.

This allows us to focus on our functions and code. What our functions do without worrying about managing updates to our server or running virtual machines. We don't even have to worry about scaling up or down.

Options:

Azure Functions

I've already been using Azure functions alot and I've a bunch of blog posts on Azure Functions already: Azure Functions

But as it stands I'll find it hard to switch I like Azure functions. They are quick and easy to setup and run.

Google Functions

Google has a few options for serverless. Google Functions is built into the Google cloud.

FireBase

Firebase is another option from Google for serverless

AWS Lambda

AWS lambda is the offering from AWS for serverless. It is a bit more tricky then the others to setup and get running.

Cloudflare Workers

Cloudflare have started into the serverless world with Cloudflare workers. Cloudflare workers give developers a place to deploy our code closer to the customers.

Over the last few years as technology has improved and the cloud providers built out more and more infrastructure, serverless began to grow.Serverless doesn't mean there is no server. What serverless means is that you don't have to worry about the server. The provider does. This allows us to…

Read More

Docker Commands

As I dig deeper and deeper into Docker. I'm finding some really useful commands that I have to keep using and reusing. As I use and learn more I will add to this guide.

Docker build command

docker build -t webapp .

Docker Tag and Push

docker tag webapp *.azurecr.io/webapp
docker push *.azurecr.io/webapp

Docker container management

Pull the latest image

docker pull *.azurecr.io/webapp

Run Container

docker run --name webapp -d -p 8090:80 *.azurecr.io/webapp

Run a container with a name of webapp, expose port 8090 and route to port 80 on the container.

Running containers

docker ps

Stop container

docker stop a456721

Remove container

docker rm a456721

This can only be run on stopped containers.

As I dig deeper and deeper into Docker. I'm finding some really useful commands that I have to keep using and reusing. As I use and learn more I will add to this guide.Docker build commanddocker build -t webapp .Docker Tag and Pushdocker tag webapp *.azurecr.io/webapp docker…

Read More

Create an Azure Container Registry

I decided to run my own registry, the more I got into docker and the more stuff I wanted to run I decided to give it a try.

It's very straight forward to spin up an Azure Container registry

Pricing

There are 3 tiers to the pricing for an Azure Container Registry.

Basic:

Price Per Day: EUR 0.141

Storage:  10 GB

Total Web Hooks: 2

Standard:

Price Per Day: EUR 0.563

Storage:  100 GB

Total Web Hooks: 10

Premium:

Price Per Day: EUR 1.406

Storage:  500 GB

Total Web Hooks: 100 - Can request more

Geo Replication: EUR 1.406 per region.

Additional Storage

Basic, Standard, Premium  €0.003/day Per GB

Create Azure Container Registry

In the Market place, head to the "Containers" Option, select the "Container Registry"

Create an Azure Container Registry

Then we need to setup our new registry.

Azure Container Registry

Once you create the new registry we wait for Azure to create it and tell us it's ready.

Azure Container registry

Next we need to get access to our new registry so we can log in and load our images. In the registry menu, select "Access Keys" - I set the admin user to enable so I can use a username / password to access my container registry.

Azure Container Registry Access Keys

Once you have these we need to log into it from docker, by default docker will log into docker hub.

docker login serversncodedemo.azurecr.io

This will then prompt for the username / password from the Azure container registry Access keys.

That's it your now logged into your own Container registry.

To push an image to your own registry you need to tag the image as your registry.

docker tag demowebapp serversncodedemo.azurecr.io/demowebapp
docker push serversncodedemo.azurecr.io/demowebapp

I decided to run my own registry, the more I got into docker and the more stuff I wanted to run I decided to give it a try.It's very straight forward to spin up an Azure Container registryPricingThere are 3 tiers to the pricing for an Azure Container Registry.…

Read More

CRON Expressions

Last week I blogged about Azure Timer functions. These functions use CRON Expressions to set the timers.

I created this post of a list of some useful and handy CRON Expressions to help me as I try to automate things. This list will grow as I do more work with automating all the things.

A CRON Expression contains six fields.

{second} {minute} {hour} {day} {month} {day-of-week}

"0 */5 * * * *"  - Every 5 Minutes.

"0 0 * * * *" - At the top of every hour.

"0 30 8 * * *" - At 8:30 AM every day

"0 30 11 * * 1-5" - At 11:30 AM every week day. (Monday - Friday)

"0 0 9 * * 1" - At 9:00 AM every Monday.

"0 0 9,12,20 * * *" - At 9:00 AM, 12:00 PM, 20:00 PM

"0 0 9-18 * * *"  - Every hour between 9:00 AM and 18:00 PM

"0 0 9-18 * * 1-5" - Every hour between 9:00 AM and 18:00 PM every week day. (Monday - Friday)

Last week I blogged about Azure Timer functions. These functions use CRON Expressions to set the timers. I created this post of a list of some useful and handy CRON Expressions to help me as I try to automate things. This list will grow as I do more work with…

Read More

Azure Timer Functions

A quick getting started guide for Azure Timer functions. Timer triggers give us alot more options to automate things. With Azure timer functions we don't have to take care of the timer Azure handles that. We can focus on the code and what our function should do.

CRON Expressions

Azure timer functions use a CRON expression for the schedule. CRON Expressions can be a bit confusing at first but with some time they make sense and really easy to configure and use.

A CRON Expression contains six fields.

{second} {minute} {hour} {day} {month} {day-of-week}

Each field is separated by a space. The value of the fields can vary and this is where I think alot of people get lost.

Examples of values:

A specific value:

"0 */5 * * * *"  - Every 5 Minutes.

"0 0 */6 * * *" - Once every 6 hours.

Note the */X this sets the trigger to every X.

"0 0 * * * *" - At the top of every hour.

"0 30 8 * * *" - At 8:30 AM every day

"0 30 11 * * 1-5" - At 11:30 AM every week day. (Monday - Friday)

To specify months or days you can use numeric values, names, or abbreviations of names:

  • For days, the numeric values are 0 to 6 where 0 starts with Sunday.
  • Names are in English. For example: Monday, January.
  • Names are case-insensitive.
  • Names can be abbreviated. Three letters is the recommended abbreviation length.  For example: Mon, Jan.

The default time zone used with the CRON expressions is Coordinated Universal Time (UTC). Azure Timer functions can run in other time zones to change the time zone you need to add a setting in the Function.json

WEBSITE_TIME_ZONE - "Eastern Standard Time"

For a full list of Azure Time zones see here

Creating a function

In our Azure Portal Go to our functions. If you haven't checked them out, see my getting started guide. For all my Azure function posts.

Create a new Function, on the wizard select the "Timer Trigger" function.

Create an Azure Timer Function

We then need to name our new function.

We can also set a schedule by default. The Timer function I just created uses a every 5 minutes expression: "0 */5 * * * *"

Create our new Timer function. 

Now that we have created a function. The default code will write to the log every 5 minutes.

Default Function will write to it's log.

So that's it, we can now code up our function as we want and Automate all the things.

To change the timer on the function just head to the function.json file

{
  "bindings": [
    {
      "name": "myTimer",
      "type": "timerTrigger",
      "direction": "in",
      "schedule": "0 */5 * * * *"
    }
  ],
  "disabled": false
}

You can see the schedule settings here. Changing it and resaving it will update the triggers timer.

A quick getting started guide for Azure Timer functions. Timer triggers give us alot more options to automate things. With Azure timer functions we don't have to take care of the timer Azure handles that. We can focus on the code and what our function should do.CRON ExpressionsAzure timer…

Read More