Table of Contents

Create your first service - "Hello World"

Create a 'hello world' service from scratch with step-by-step instructions and in-depth explanation of the basic concepts.
This tutorial will teach you the very basics of what makes a Firefly service tick.

Prerequisites

  1. Windows 10/11
  2. Visual studio 2019/2022
  3. Phoesion Glow Blaze , with Reactor running (see getting started guide)

Sample Code

You can download the Sample Code archive from the downloads section.
This tutorial follows the 0_Hello_World sample in the archive. (View code on GitHub)

Introduction

In this tutorial you will create a simple Firefly service with one module and one REST action.
The action will return the string "Hello World" when we hit it from the browser.

What is a firefly service?

Services are hosted and supervised by the cloud entity called Phoesion Glow Firefly.
When a new deployment occurs the firefly entity will download your files from the Phoesion Glow Lighthouse entity and run it.
You can write a Firefly service using the Phoesion Glow SDK.
A firefly service consists of a set of Modules.

What is a firefly service Module ?

A module is a class that inherits from FireflyModule.
The module's methods are called Actions (marked with [Action] attribute) and can be accessed from the outside world (eg. a browser)
This tutorial will show you how to create a module and an action that can be accessed from the browser. (creating a REST api)

Create C# Solution and Projects

First we need to setup our C# solution and project.
Since this is a simple single-service project with no public api, we only need one c# project.
We assume a fake company namespace Foompany in order to keep things in order. The services of this imaginary company will be under namespace Foompany.Services.

1. Create a new Solution

Create a new solution using Visual Studio with a Firefly Service Project project.
VisualStudio_Create_New_Solution_Type

Note

If you can't find the Firefly Service Project template, make sure you have Phoesion Glow Templates visual studio extension installed. If not you can get it from the Visual Studio Marketplace

2. Configure new Project

Name your new project and solution :

Project name : Foompany.Services.HelloWorld
Location : <Set your location>
Solution name : Foompany.Services

VisualStudio_Create_New_Solution_Configs

Create a Firefly Module

Now we need to create a firefly module with an action.
In the folder Modules, delete the Sample.cs that was generated by the template and create a new module named Greeter.cs like so
VisualStudio_Create_Module_Class_Greeter

Create an Action

In the new Greeter.cs, delete the Action1 function that was created by the template and add the following :

[Action(Methods.GET)]
public string SayHello()
{
    return "Hello world!";
}

Rebuild the solution and make sure everything compiles without any errors

Test/Debug your service locally

To start your service simply set it a Startup Project in Visual Studio and press F5. Wait until you see the Service Started! message, then you can test it by opening a browser and going to

You should see a "Hello World" message in your browser.
Hello World Browser

Video Tutorial

You can also watch a video tutorial for setting up your machine and creating your first service. Watch on YouTube : Phoesion Glow basics - Part 1 - Hello World service