Git Product home page Git Product logo

urlshortening's Introduction

URL Shortening

A simple URL shortening service using .NET and Azure.

Deploy to Azure GitHub license Build status

Deployment

You can deploy to Azure using the above button. Prior to deployment you should have an existing Azure Storage Account. Copy the connection string to the clipboard; you will be prompted for it during deployment in a field labeled AzureStorageConnectionString.

Once deployed you can add or modify the connection string for AzureStorage.

  1. Click Manage when deployment is finished (or browse to the web app on the Azure Portal
  2. Click Settings
  3. Select Application settings
  4. Click Show Connection Strings
  5. Add a new Custom connection string named AzureStorage and paste the connection string to an Azure Storage Account

If you do not provide the Azure Storage connection string an in-memory URL Alias repository will be used. In that case short URLs will break when the web app is restarted.

Architecture

UrlShortener contains the core logic. There are interfaces you can use to customize the specific mechanics:

  • IHashScheme - Used to generate the short URL. Should generate an appropriate short "hash" from a long string. A default implementation is provided which is based on Base64 encoding of SHA1. Implementations must also provide a way to iteratetively generate new hashes from the same input in the case of a hash collision.
  • IAliasRepository - Dictionary-like persistence of "alias" or "hash" of one string (the key) to another (the value). Used to save mapping between short and long URLs. The default uses Azure Table storage. The fallback uses an in-memory Dictionary.
  • IUrlUnwrapper - Responsible for resolving a direct URL to a resource. For example the provided URL might already be a 'short URL', which could lead to multiple redirects or a redirect loop. The default uses WebClient.

Contributing

  • Natural enhancements to this project would be:
  • Core logic in the Durwella.UrlShortening project must be unit tested.
  • Unit tests should be written using 3 paragaphs corresponding to Arrange, Act and Assert
  • Build must remain clean (no warnings, tests passing)
  • Code Analysis issues should not be introduced
  • Must be deployable to Azure using AzureDeploy.net

References

URL Shortening: Hashes In Practice
Nice article by Jeff Atwood. Historical yet relevant.

Using Custom Azure Resource Management Templates
Helpful for understanding what is going on with the azuredeploy.json file

Testing Azure deployment can be done from Azure PowerShell something like this...

Switch-AzureMode -Name AzureResourceManager
$site = "uniqueNameARMTest123"
$pw = read-host -AsSecureString
New-AzureResourceGroup -TemplateFile .\azuredeploy.json -Name $site -DeploymentName $site `
    -Verbose -Location "South Central US" -hostingPlanName $site -hostingPlanLocation "South Central US" `
    -siteName $site -repoUrl "https://github.com/Durwella/UrlShortening" -branch "master" `
    -title $site -adminPassword $pw
# Testing...
Remove-AzureResourceGroup -Name $site

urlshortening's People

Contributors

jfoshee avatar

Stargazers

Richard Phipps avatar Shaun Foce avatar Ihor Chulinda avatar Matthew McLeod avatar Anthony Clendenen avatar Jean-Benoit Paux avatar Neal Miller avatar Sukesh Ashok Kumar avatar Biagio Paruolo avatar Victor avatar Chris Love avatar  avatar Mikaelo avatar Reuben Bond avatar  avatar

Watchers

Hank Beasley avatar  avatar James Cloos avatar

urlshortening's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.