Skip to content

Commit

Permalink
Initial Repo Population
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuart R. Kirk committed Oct 11, 2020
1 parent bf3f14a commit 15d95ef
Show file tree
Hide file tree
Showing 226 changed files with 170,519 additions and 0 deletions.
48 changes: 48 additions & 0 deletions aro-mssql/mssql.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: apps/v1beta1
kind: Deployment
metadata:
name: mssql-deployment
spec:
replicas: 1
template:
metadata:
labels:
app: mssql
spec:
terminationGracePeriodSeconds: 10
containers:
- name: mssql
image: mcr.microsoft.com/mssql/server:2017-latest
ports:
- containerPort: 1433
env:
- name: MSSQL_PID
value: "Developer"
- name: ACCEPT_EULA
value: "Y"
- name: SA_PASSWORD
valueFrom:
secretKeyRef:
name: mssql
key: SA_PASSWORD
volumeMounts:
- name: mssqldb
mountPath: /var/opt/mssql
volumes:
- name: mssqldb
persistentVolumeClaim:
claimName: mssql-data
---
apiVersion: v1
kind: Service
metadata:
name: mssql-deployment
spec:
selector:
app: mssql
ports:
- protocol: TCP
port: 1433
targetPort: 1433
type: LoadBalancer

21 changes: 21 additions & 0 deletions aro-mssql/pvc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
kind: StorageClass
apiVersion: storage.k8s.io/v1beta1
metadata:
name: azure-disk
provisioner: kubernetes.io/azure-disk
parameters:
storageaccounttype: Standard_LRS
kind: Managed
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: mssql-data
annotations:
volume.beta.kubernetes.io/storage-class: azure-disk
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 8Gi
Binary file added function-app-container/.DS_Store
Binary file not shown.
103 changes: 103 additions & 0 deletions function-app-container/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
*.egg-info/
.installed.cfg
*.egg

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# pyenv
.python-version

# celery beat schedule file
celerybeat-schedule

# SageMath parsed files
*.sage.py

# dotenv
.env

# virtualenv
.venv
venv/
ENV/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/

index.html
12 changes: 12 additions & 0 deletions function-app-container/BlobTrigger/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"scriptFile": "main.py",
"bindings": [
{
"name": "myblob",
"type": "blobTrigger",
"direction": "in",
"path": "samples-workitems/{name}",
"connection":"AzureWebJobsStorage"
}
]
}
8 changes: 8 additions & 0 deletions function-app-container/BlobTrigger/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import logging

import azure.functions as func

def main(myblob: func.InputStream):
logging.info(f"Python blob trigger function processed blob \n"
f"Name: {myblob.name}\n"
f"Blob Size: {myblob.length} bytes")
7 changes: 7 additions & 0 deletions function-app-container/BlobTrigger/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# BlobTrigger

The `BlobTrigger` makes it incredibly easy to react to new Blobs inside of Azure Blob Storage. This sample demonstrates a simple use case of processing data from a given Blob.

## How it works

For a `BlobTrigger` to work, you provide a path which dictates where the blobs are located inside your container, and can also help restrict the types of blobs you wish to return. For instance, you can set the path to `samples/{name}.png` to restrict the trigger to only the samples path and only blobs with ".png" at the end of their name.
5 changes: 5 additions & 0 deletions function-app-container/CosmosDBTrigger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Cosmos DB Trigger
A function that will be run whenever documents change in a document collection.

## How it works
This template shows a Cosmos DB trigger binding in the function.json file and a Python function that uses that binding. The function writes log messages when Cosmos DB records are modified.
8 changes: 8 additions & 0 deletions function-app-container/CosmosDBTrigger/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import logging

import azure.functions as func


def main(documents: func.DocumentList) -> str:
if documents:
logging.info('Document id: %s', documents[0].id)
10 changes: 10 additions & 0 deletions function-app-container/CosmosDBTrigger/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"bindings": [
{
"type": "cosmosDBTrigger",
"name": "documents",
"direction": "in",
"leaseCollectionName": "leases"
}
]
}
8 changes: 8 additions & 0 deletions function-app-container/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FROM mcr.microsoft.com/azure-functions/python:2.0

ENV host:logger:consoleLoggingMode=always

COPY . /home/site/wwwroot

RUN cd /home/site/wwwroot && pip install -r requirements.txt
RUN pip install ansible[azure]
16 changes: 16 additions & 0 deletions function-app-container/HttpTrigger/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"scriptFile": "main.py",
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"type": "http",
"direction": "out",
"name": "$return"
}
]
}
40 changes: 40 additions & 0 deletions function-app-container/HttpTrigger/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import logging
import azure.functions as func
import subprocess
import json

def main(req: func.HttpRequest) -> func.HttpResponse:
logging.info('Python HTTP trigger function processed a request.')

subscription_id = req.params.get('subscription_id')
tenant = req.params.get('tenant')
secret = req.params.get('secret')
client = req.params.get('client_id')

body = req.get_body()

f = open("./playbook.yml", "wb")
f.write(body)
f.close()

cmd = "export AZURE_CLIENT_ID=" + client + "; "
cmd += "export AZURE_SECRET=" + secret + "; "
cmd += "export AZURE_SUBSCRIPTION_ID=" + subscription_id + "; "
cmd += "export AZURE_TENANT=" + tenant + "; "
cmd += "ansible-playbook ./playbook.yml"

process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True)
output, error = process.communicate()

# output = cmd
# error = "no error"
try:
x = json.dumps({ 'output': str(output), 'error': str(error) })
#if len(str(output) + str(error)) > 0:
# return func.HttpResponse("XXXXXX", headers={"Access-Control-Allow-Origin": "*"})
#else:
# return func.HttpResponse("YYYYYY", headers={"Access-Control-Allow-Origin": "*"})
return func.HttpResponse(x, headers={"Access-Control-Allow-Origin": "*"})

except Exception as e:
return func.HttpResponse("EXCEPTION", headers={"Access-Control-Allow-Origin": "*"})
7 changes: 7 additions & 0 deletions function-app-container/HttpTrigger/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# HttpTrigger

The `HttpTrigger` makes it incredibly easy to have your functions executed via an HTTP call to your function.

## How it works

When you call the function, be sure you checkout which security rules you apply. If you're using an apikey, you'll need to include that in your request.
21 changes: 21 additions & 0 deletions function-app-container/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) Microsoft Corporation. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE
12 changes: 12 additions & 0 deletions function-app-container/QueueTrigger/function.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"scriptFile": "main.py",
"bindings": [
{
"name": "msg",
"type": "queueTrigger",
"direction": "in",
"queueName": "samplequeue",
"connection":"AzureWebJobsStorage"
}
]
}
8 changes: 8 additions & 0 deletions function-app-container/QueueTrigger/main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import logging

import azure.functions as func


def main(msg: func.QueueMessage) -> None:
logging.info('Python queue trigger function processed a queue item: %s',
msg.get_body().decode('utf-8'))
7 changes: 7 additions & 0 deletions function-app-container/QueueTrigger/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# QueueTrigger

The `QueueTrigger` makes it incredibly easy to react to new Queues inside of Azure Queue Storage. This sample demonstrates a simple use case of processing data from a given Queue.

## How it works

For a `QueueTrigger` to work, you provide a path which dictates where the queue messages are located inside your container.
Loading

0 comments on commit 15d95ef

Please sign in to comment.