Skip to content

Instantly share code, notes, and snippets.

Thomas Pentenrieder ThomasPe

Block or report user

Report or block ThomasPe

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@ThomasPe
ThomasPe / index.js
Created Oct 3, 2018
Delete | Azure Functions + NodeJs + Table Storage
View index.js
const azure = require('azure-storage');
const tableService = azure.createTableService();
const tableName = "mytable";
module.exports = function (context, req) {
context.log('Start ItemDelete');
const id = req.query.id;
if (id) {
@ThomasPe
ThomasPe / index.js
Created Oct 3, 2018
Update | Azure Functions + NodeJs + Table Storage
View index.js
const azure = require('azure-storage');
const tableService = azure.createTableService();
const tableName = "mytable";
module.exports = function (context, req) {
context.log('Start ItemUpdate');
if (req.body) {
@ThomasPe
ThomasPe / index.js
Last active Oct 3, 2018
Create | Azure Functions + NodeJs + Table Storage
View index.js
// Reference to the Azure Storage SDK
const azure = require('azure-storage');
// Reference to the uuid package which helps us to create
// unique identifiers for our PartitionKey
const uuid = require('uuid/v1');
// The TableService is used to send requests to the database
const tableService = azure.createTableService();
//
const tableName = "mytable";
@ThomasPe
ThomasPe / index.js
Created Oct 2, 2018
Blank JavaScript Azure Function
View index.js
module.exports = async function (context, req) {
context.log('JavaScript HTTP trigger function processed a request.');
context.res = {
status: 200,
body: "Result message"
};
};
@ThomasPe
ThomasPe / index.js
Last active Oct 2, 2018
Read | Azure Functions + NodeJs + Table Storage
View index.js
const azure = require('azure-storage');
const tableService = azure.createTableService();
const tableName = "mytable";
module.exports = function (context, req) {
context.log('Start ItemRead');
const id = req.query.id;
if (id) {
@ThomasPe
ThomasPe / uploadSite.js
Created Jul 30, 2018
Upload html file to Azure Storage static web hosting
View uploadSite.js
function uploadSite(page){
context.log("Upload site ");
var blobService = storage.createBlobService();
// create $web container
blobService.createContainerIfNotExists('$web', function(){
// upload index.html to $web container
const options = { contentSettings: { contentType: 'text/html' } }
blobService.createBlockBlobFromText("$web", "index.html", page, options, function (error) {
@ThomasPe
ThomasPe / renderSite.js
Created Jul 30, 2018
Render index.html from mustache templates & dynamic data
View renderSite.js
function renderSite(){
context.log("render site");
var pageFile = "";
mu.compileText('index.mustache', context.bindings.indexTemplate, function (err, parsed) {
var renderstream = mu.render(parsed, { news: mynews, links: mylinks });
renderstream.on('data', function (data) {
pageFile += data;
});
renderstream.on('end', function (data) {
context.log("done creating index.html");
@ThomasPe
ThomasPe / prepareTemplates.js
Created Jul 30, 2018
Preparing mustache header & footer files
View prepareTemplates.js
function prepareTemplates(){
context.log('prepare Templates');
mu.compileText('header.mustache', context.bindings.headerTemplate, function () {
mu.compileText('footer.mustache', context.bindings.footerTemplate, function () {
renderSite();
});
});
}
@ThomasPe
ThomasPe / getData.js
Created Jul 30, 2018
Get WordPress data from REST API
View getData.js
function getData(){
context.log('get data');
var options = {
url: 'https://windowsarea.de/wp-json/wp/v2/posts',
method: 'GET',
json: true
}
request(options, function (error, response, data) {
@ThomasPe
ThomasPe / index.mustache
Created Jul 30, 2018
Sample index.mustache
View index.mustache
{{> header.mustache}}
<h1>WindowsArea.de News</h1>
<ul>
{{#news}}
<li><a href="{{link}}" target="_blank">{{title.rendered}}</a></li>
{{/news}}
</ul>
<h1>My Links</h1>
You can’t perform that action at this time.