Jekyll-Markdown: Add voting to a Blog Post - How to
November 22, 2025 23:18
David Jones MVP
web
jekyll
web
markdown
azurefunction
survey
voting
state
22 Nov 2025 23:18:26
David Jones MVP
web jekyll web markdown azurefunction survey voting state
web jekyll web markdown azurefunction survey voting state
A Detailed How-To on adding voting to a Jekyll Markdown Blog Post using an Azure Function and Azure Blob Storage. Incomplete
- Clone the repository djaus2/VotesJekyllMarkdown
- Use this as a starting point for your own implementation.
- You will need to apply some configuration settings to make it work for your own Azure Function and Blob Storage.
- Choose a unique project name
YOUR_PROJECT_NAMEfor the `VotesSurveyFn’ Azure Function project.- This needs to be unique within Azure as the functions URL will be
https://YOUR_PROJECT_NAME.azurewebsites.net/api/emoji - Change the project name in the Azure Function code and configuration accordingly as well a change the two VotesFolderFn folder names in the repository accordingly. You will need to rename the solution file as well and edit it to point to the renamed project by changing its folder name.
- You may wish the change the API name,
emojibut this change is not needed. If so you will need to rename the emoji class and emoji.cs in the Azure Function project as well as change any references to it in the blog post code. - Look for now ee will use:http://localhost:7050- The port 7050 is defined in
launchSettings.jsonin the Azure Function project.
- The port 7050 is defined in
http://localhost:7050/api/emojihttp://localhost:7050/api/emoji?code=YOUR_FUNCTION_KEY
More onYOUR_FUNCTION_KEYlater.
- Later when we deploy to Azure we will use:
https://YOUR_PROJECT_NAME.azurewebsites.nethttps://YOUR_PROJECT_NAME.azurewebsites.net/api/emojihttps://YOUR_PROJECT_NAME.azurewebsites.net/api/emoji?code=YOUR_FUNCTION_KEY
More onYOUR_FUNCTION_KEYlater.
- Also in
launchSettings.json add a custom value for ADMIN_SECRET used in the function code to validate admin access when resetting votes. For local testing you can set this to any value you like, e.g.,myadminsecret`. - Check that the project builds as-is. 😀
- In
- Run the Azure Function project locally and check that you get a message displaying the local URL.
- You should get a response indicating that the function is running.
- This needs to be unique within Azure as the functions URL will be
- Choose a unique Azure Blob Storage container name
YOUR_CONTAINER_NAMEto store the vote counts.- I often when wanting to use a generic name lead with, say, my githihub handle.
- e.g.,
djaus2votescontainerto help ensure uniqueness.
- e.g.,
- Create the Blob Storage container in your Azure Storage Account.
- See the repository djaus2/VotesJekyllMarkdown ReadMe under Usage on how to create the Blob Storage container using the Azure CLI, or see the previous blog post for alternatives.
- Note that the container name must globally unique and be lowercase.
- Make a note of the Table connection string for your Azure Storage Account as you will need this later.
- I often when wanting to use a generic name lead with, say, my githihub handle.
- Update the Azure Function code configuration to use your Blob Storage container.
- Update the Azure Function code to use this container name.
- Look for, and update in the blog code accordingly:
YOUR_CONTAINER_NAME
- Look for, and update in the blog code accordingly:
- Add the Blob Storage connection string as an Environment variable in the Azure Function project settings.
- Go to ‘launchSettings.json’ in the Azure Function project.
- Under Environment Variables, add a new variable:
- Name:
"AzureWebJobsStorage" - Value: Your Blob Storage connection string.
- Name:
- Update the Azure Function code to use this container name.
- Test things thus far:
- Run the Azure Function project and in a browser go to
http://localhost:7050/api/emoji
- You should get a response indicating the count as zero:
'{"value":0}'or Pretty Printed:{ "value": 0 }- In a browser try `http://localhost:7050/api/emoji?action=reset&extent=all&secret=ADMIN_SECRET` replacing `ADMIN_SECRET` with the value you set in the Environment variable in `launchSettings.json`. - You should get a response indicating that the votes have been reset such as:
{"ok":true,"wiped":"all"}- Tryhttp://localhost:7050/api/emoji?action=get&ns=myblog&key=home - You should get a response indicating the count as zero:
{"value":0}
- Tryhttp://localhost:7050/api/emoji?action=hit&ns=myblog&key=home - You should get a response indicating the count as one:
{"value":1} - In Azure check the Blob Container and see that a Table
MySurveyTallieshas been created and has an entry myBlog with a value of 1 as well asMySurveyLogswith a log entry.- Ps: Check in emoji.cs where these table names are defined. You can override these with an entry in launchSettings.json if you wish. - Experiment with these direct actions to get a feel for how they work. 😀 —
- Run the Azure Function project and in a browser go to
So far we have:
- Azure Function Project
- Unique Azure Function Project Name
YOUR_CONTAINER_NAME - An API endpoint within the function, eg.
emoji ADMIN_SECRETfor admin access as an Environment variable, for admin actions such as resetting the Blob tables.- Can run locally.
- Can be access locally via
http://localhost:7050/api/emoji - Or when deployed to Azure via
https://YOUR_PROJECT_NAME.azurewebsites.net/api/emoji
- Can be access locally via
- Unique Azure Function Project Name
- Azure Blob Storage Container
- Unique Blob Storage Container Name
YOUR_CONTAINER_NAME - A connection string
AzureWebJobsStorageas an Environment variable in the Azure Function project settings. - Two Blob Tables created when the function is run:
- Two Table names defined in the Azure Function code.
MySurveyTalliesMySurveyLogs
- Two Table names defined in the Azure Function code.
- Unique Blob Storage Container Name
M O R E - C O M I N G !
| Topic | Subtopic | |
| This Category Links | ||
| Category: | Web Sites Index: | Web Sites |
| < Prev: | Jekyll-Markdown | Add voting to a Blog Post |