mirror of
https://github.com/jlengrand/cellar.git
synced 2026-03-10 08:01:19 +00:00
First Azure attempts
This commit is contained in:
7
cellar-azure-backups/.funcignore
Normal file
7
cellar-azure-backups/.funcignore
Normal file
@@ -0,0 +1,7 @@
|
||||
*.js.map
|
||||
*.ts
|
||||
.git*
|
||||
.vscode
|
||||
local.settings.json
|
||||
test
|
||||
tsconfig.json
|
||||
94
cellar-azure-backups/.gitignore
vendored
Normal file
94
cellar-azure-backups/.gitignore
vendored
Normal file
@@ -0,0 +1,94 @@
|
||||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
lerna-debug.log*
|
||||
|
||||
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||
|
||||
# Runtime data
|
||||
pids
|
||||
*.pid
|
||||
*.seed
|
||||
*.pid.lock
|
||||
|
||||
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||
lib-cov
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# nyc test coverage
|
||||
.nyc_output
|
||||
|
||||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||
.grunt
|
||||
|
||||
# Bower dependency directory (https://bower.io/)
|
||||
bower_components
|
||||
|
||||
# node-waf configuration
|
||||
.lock-wscript
|
||||
|
||||
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||
build/Release
|
||||
|
||||
# Dependency directories
|
||||
node_modules/
|
||||
jspm_packages/
|
||||
|
||||
# TypeScript v1 declaration files
|
||||
typings/
|
||||
|
||||
# Optional npm cache directory
|
||||
.npm
|
||||
|
||||
# Optional eslint cache
|
||||
.eslintcache
|
||||
|
||||
# Optional REPL history
|
||||
.node_repl_history
|
||||
|
||||
# Output of 'npm pack'
|
||||
*.tgz
|
||||
|
||||
# Yarn Integrity file
|
||||
.yarn-integrity
|
||||
|
||||
# dotenv environment variables file
|
||||
.env
|
||||
.env.test
|
||||
|
||||
# parcel-bundler cache (https://parceljs.org/)
|
||||
.cache
|
||||
|
||||
# next.js build output
|
||||
.next
|
||||
|
||||
# nuxt.js build output
|
||||
.nuxt
|
||||
|
||||
# vuepress build output
|
||||
.vuepress/dist
|
||||
|
||||
# Serverless directories
|
||||
.serverless/
|
||||
|
||||
# FuseBox cache
|
||||
.fusebox/
|
||||
|
||||
# DynamoDB Local files
|
||||
.dynamodb/
|
||||
|
||||
# TypeScript output
|
||||
dist
|
||||
out
|
||||
|
||||
# Azure Functions artifacts
|
||||
bin
|
||||
obj
|
||||
appsettings.json
|
||||
local.settings.json
|
||||
19
cellar-azure-backups/MonitoringDeadHTTPTrigger/function.json
Normal file
19
cellar-azure-backups/MonitoringDeadHTTPTrigger/function.json
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"bindings": [
|
||||
{
|
||||
"authLevel": "anonymous",
|
||||
"type": "httpTrigger",
|
||||
"direction": "in",
|
||||
"name": "req",
|
||||
"methods": [
|
||||
"get",
|
||||
"post"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "http",
|
||||
"direction": "out",
|
||||
"name": "res"
|
||||
}
|
||||
]
|
||||
}
|
||||
11
cellar-azure-backups/MonitoringDeadHTTPTrigger/index.js
Normal file
11
cellar-azure-backups/MonitoringDeadHTTPTrigger/index.js
Normal file
@@ -0,0 +1,11 @@
|
||||
module.exports = async function (context, req) {
|
||||
context.log('JavaScript HTTP trigger function processed a request.');
|
||||
|
||||
const name = (req.query.name || (req.body && req.body.name));
|
||||
const responseMessage = req;
|
||||
|
||||
context.res = {
|
||||
// status: 200, /* Defaults to 200 */
|
||||
body: responseMessage
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "Azure"
|
||||
}
|
||||
10
cellar-azure-backups/TimerTrigger1/function.json
Normal file
10
cellar-azure-backups/TimerTrigger1/function.json
Normal file
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"bindings": [
|
||||
{
|
||||
"name": "myTimer",
|
||||
"type": "timerTrigger",
|
||||
"direction": "in",
|
||||
"schedule": "0 */12 * * * *"
|
||||
}
|
||||
]
|
||||
}
|
||||
9
cellar-azure-backups/TimerTrigger1/index.js
Normal file
9
cellar-azure-backups/TimerTrigger1/index.js
Normal file
@@ -0,0 +1,9 @@
|
||||
module.exports = async function (context, myTimer) {
|
||||
var timeStamp = new Date().toISOString();
|
||||
|
||||
if (myTimer.isPastDue)
|
||||
{
|
||||
context.log('JavaScript is running late!');
|
||||
}
|
||||
context.log('JavaScript timer trigger function ran!', timeStamp);
|
||||
};
|
||||
11
cellar-azure-backups/TimerTrigger1/readme.md
Normal file
11
cellar-azure-backups/TimerTrigger1/readme.md
Normal file
@@ -0,0 +1,11 @@
|
||||
# TimerTrigger - JavaScript
|
||||
|
||||
The `TimerTrigger` makes it incredibly easy to have your functions executed on a schedule. This sample demonstrates a simple use case of calling your function every 5 minutes.
|
||||
|
||||
## How it works
|
||||
|
||||
For a `TimerTrigger` to work, you provide a schedule in the form of a [cron expression](https://en.wikipedia.org/wiki/Cron#CRON_expression)(See the link for full details). A cron expression is a string with 6 separate expressions which represent a given schedule via patterns. The pattern we use to represent every 5 minutes is `0 */5 * * * *`. This, in plain text, means: "When seconds is equal to 0, minutes is divisible by 5, for any hour, day of the month, month, day of the week, or year".
|
||||
|
||||
## Learn more
|
||||
|
||||
<TODO> Documentation
|
||||
0
cellar-azure-backups/TimerTrigger1/sample.dat
Normal file
0
cellar-azure-backups/TimerTrigger1/sample.dat
Normal file
15
cellar-azure-backups/host.json
Normal file
15
cellar-azure-backups/host.json
Normal file
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"version": "2.0",
|
||||
"logging": {
|
||||
"applicationInsights": {
|
||||
"samplingSettings": {
|
||||
"isEnabled": true,
|
||||
"excludedTypes": "Request"
|
||||
}
|
||||
}
|
||||
},
|
||||
"extensionBundle": {
|
||||
"id": "Microsoft.Azure.Functions.ExtensionBundle",
|
||||
"version": "[1.*, 2.0.0)"
|
||||
}
|
||||
}
|
||||
5
cellar-azure-backups/package-lock.json
generated
Normal file
5
cellar-azure-backups/package-lock.json
generated
Normal file
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"name": "cellar-azure-backups",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 1
|
||||
}
|
||||
11
cellar-azure-backups/package.json
Normal file
11
cellar-azure-backups/package.json
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"name": "cellar-azure-backups",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"scripts": {
|
||||
"start": "func start",
|
||||
"test": "echo \"No tests yet...\""
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {}
|
||||
}
|
||||
4
cellar-azure-backups/proxies.json
Normal file
4
cellar-azure-backups/proxies.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"$schema": "http://json.schemastore.org/proxies",
|
||||
"proxies": {}
|
||||
}
|
||||
@@ -1,10 +1,9 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
influx backup $BACKUP_NAME --token $CELLAR_ADMIN_TOKEN --host $CELLAR_HOST
|
||||
BACKUP_NAME=$(date +'%d-%m-%Y-%H')
|
||||
echo "Creating $BACKUP_NAME.zip"
|
||||
|
||||
cd /home/julien/backups
|
||||
influx backup $BACKUP_NAME --token $CELLAR_ADMIN_TOKEN
|
||||
zip -r $BACKUP_NAME.zip $BACKUP_NAME
|
||||
az storage blob upload \
|
||||
--account-name "cellarbackupstorage" \
|
||||
--container-name "cellar-backups" \
|
||||
--name $BACKUP_NAME.zip \
|
||||
--file $BACKUP_NAME.zip \
|
||||
--auth-mode login
|
||||
rm -r $BACKUP_NAME
|
||||
Reference in New Issue
Block a user