Skip to content

Instantly share code, notes, and snippets.

View sjwaight's full-sized avatar
😎
Happy Days

Simon Waight sjwaight

😎
Happy Days
View GitHub Profile
@sjwaight
sjwaight / FunctionSkillSampleBody.py
Last active August 26, 2021 08:02
Sample Azure Function main function showing how to setup handling Alexa skill.
def main(req: func.HttpRequest) -> func.HttpResponse:
skill_builder = SkillBuilder()
skill_builder.skill_id = os.environ["AlexaSkillID"]
skill_builder.add_request_handler(LaunchRequestHandler())
skill_builder.add_request_handler(ReadTopFiveItems())
skill_builder.add_request_handler(ReadItemsFromDate())
skill_builder.add_request_handler(HelpIntentHandler())
skill_builder.add_request_handler(CancelOrStopIntentHandler())
skill_builder.add_request_handler(SessionEndedRequestHandler())
@sjwaight
sjwaight / LaunchAndExceptionSample.py
Last active August 26, 2021 08:51
Sample Launch Request and Exception Catch All handlers for an Alexa Skill.
class LaunchRequestHandler(AbstractRequestHandler):
"""Handler for LaunchRequest."""
def can_handle(self, handler_input):
return ask_utils.is_request_type("LaunchRequest")(handler_input)
def handle(self, handler_input):
logging.info("Called Skill Handler for LaunchRequest Intent.")
speak_output = "Hi there! I'm the Azure news service and I can read you the latest Azure cloud news.\r\nYou can ask for the latest news by saying <break time='0.5s'/>'latest news', or ask for the top news items from a specific date by saying <break time='0.5s'/>'top news from'<break time='0.5s'/> and then the date, making sure to include the year."
@sjwaight
sjwaight / SampleIntentHandler.py
Last active August 26, 2021 08:50
Sample Alexa Intent Handler written as a Python class.
class ReadTopFiveItems(AbstractRequestHandler):
"""Handler for ReadTopFive Intent."""
def can_handle(self, handler_input):
return ask_utils.is_intent_name("ReadTopFive")(handler_input)
def handle(self, handler_input):
logging.info("Called Skill Handler for ReadTopFive Intent.")
@sjwaight
sjwaight / GeneratePresentation.py
Created July 23, 2021 05:49
Python Azure Function that can read and RSS feed and generate a PowerPoint presentation
import logging
import azure.functions as func
import os
from azure.storage.blob import BlobClient, BlobSasPermissions, generate_blob_sas
from datetime import datetime, timedelta, timezone
from pptx import Presentation
from pptx.util import Pt
@sjwaight
sjwaight / helmdeployment.yaml
Created April 20, 2021 10:40
Sample Helm deployment file showing how to pull a secret into an evironment variable
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "mvcmusicstoreweb.fullname" . }}
labels:
{{- include "mvcmusicstoreweb.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
@sjwaight
sjwaight / fullbuilddeployk8swindows.yaml
Created April 20, 2021 10:38
Complete GitHub Action showing how to build and deploy a Windows Container app to Kubernetes using Helm
name: Build Windows Container Image
on:
push:
branches: [ deploy-to-k8s ]
pull_request:
branches: [ deploy-to-k8s ]
workflow_dispatch:
env:
@sjwaight
sjwaight / values.yaml
Last active April 20, 2021 10:33
Simple Helm Chart values file for MVC Music Store ASP.NET Web Application
# Default values for mvcmusicstoreweb.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: your_repo.azurecr.io/mvcmusicstoreweb
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
@sjwaight
sjwaight / Chart.yaml
Created April 19, 2021 05:04
Simple Helm Chart definition for the MVC Music Store ASP.NET Web Application
apiVersion: v2
name: mvcmusicstoreweb
description: MVC Music Store web application
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
@sjwaight
sjwaight / buildandpushmusicstore.yaml
Created April 18, 2021 08:46
Sample GitHub Action that builds the MVC Music Store sample and pushes the container to Azure Container Registry
name: Build Windows Container Image
on:
push:
branches: [ post-containerisation ]
pull_request:
branches: [ post-containerisation ]
workflow_dispatch:
env:
@sjwaight
sjwaight / WinContainerfull.dockerfile
Created March 29, 2021 10:31
Full dockerfile that shows how to build and package an .NET Framework application for use with Windows Containers
FROM mcr.microsoft.com/dotnet/framework/sdk:4.8 AS build
WORKDIR /app
# copy csproj and restore as distinct layers
COPY MvcMusicStore-Completed/*.sln .
COPY MvcMusicStore-Completed/MvcMusicStore/*.csproj ./MvcMusicStore/
COPY MvcMusicStore-Completed/MvcMusicStore/*.config ./MvcMusicStore/
RUN nuget restore
# copy everything else and build app