/KittyServiceFabric

Simple Service Fabric Application that caches external API calls

Primary LanguageC#Apache License 2.0Apache-2.0

Kitty Service Fabric

This project is a small example of a front end API and backend stateful service for service fabric. It gets kitty pictures via (placekitten.com) and will cache them in an Azure container with an md5 reference persisted in your backend stateful service.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

Microsoft provides a free Service Fabric cluster if you want to try it there too.

Installing

Once cloned, you'll have to provide your connection string to your storage account. To get this, go into your Storage Account and click on Access Keys. you'll find "Connection String" at the bottom of the list.

Using Azure Storage Account

Copy and paste that into KittyGotBack/PackageRoot/ServiceManifest.xml:

  <CodePackage Name="Code" Version="1.0.0">
    <EntryPoint>
      <ExeHost>
        <Program>KittyGotBack.exe</Program>
      </ExeHost>
    </EntryPoint>
    <EnvironmentVariables>
      <EnvironmentVariable Name="containerConnectionString" Value="PASTE HERE!"/>
    </EnvironmentVariables>
  </CodePackage>

Using Azure Storage Emulator

A new alternative to using Azure Storage is to use the emulator. Download and instructions on setting up can be found here

Once you run init and start, the only config changes you need to make (provided you used default settings) is to set the connection string to set the variable mentioned above to:

<EnvironmentVariable Name="containerConnectionString" Value="UseDevelopmentStorage=true"/>

Once your connection string is in there, you can debug or deploy this application to see it's wonderous effects.

To debug locally, choose BuildConfiguration Debug and Platform x64.

Use your favorite REST tool like Postman to perform a GET on http://localhost:8943/api/kitties/300/300

The url path spec is /api/kitties/{width}/{height}

Change those numbers to get different sized kitty pictures.

Running the tests

No Tests for this, sorry.

Deployment

Deployment is outside the scope of this demo. See Microsoft Documentation for more information. Deploy and remove applications using PowerShell Tutorial: deploy an application with CI/CD to a Service Fabric cluster

Built With

  • Dropwizard - The web framework used
  • Maven - Dependency Management
  • ROME - Used to generate RSS Feeds

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

  • This couldn't have been possible without Microsoft and placekitten.com