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 / 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
@sjwaight
sjwaight / VS.dockerfile
Last active March 29, 2021 05:03
Default Visual Studio 2019 Container Tools Dockerfile
#Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
#For more information, please see https://aka.ms/containercompat
FROM mcr.microsoft.com/dotnet/framework/aspnet:4.8-windowsservercore-ltsc2019
ARG source
WORKDIR /inetpub/wwwroot
COPY ${source:-obj/Docker/publish} .
@sjwaight
sjwaight / musicstoreentities-secret.yml
Created March 29, 2021 03:59
Single Kubernetes secret we can deploy using kubectl
apiVersion: v1
kind: Secret
metadata:
name: dbconnection
type: Opaque
data:
connstring: U2Vy_NOT_A_VALID_BASE_64_sdoinsdcoin=
@sjwaight
sjwaight / session-sql-web-config.xml
Last active March 20, 2021 00:03
web.config sample showing SQL Server session state configuration
<sessionState mode="Custom" customProvider="DefaultSessionProvider">
<providers>
<add name="DefaultSessionProvider"
type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
connectionStringName="MusicStoreEntities" />
</providers>
</sessionState>
@sjwaight
sjwaight / sqlconnection-env.xml
Created March 19, 2021 04:04
SQL Connection web.config section showing use of ConfigBuilder Environment source
<connectionStrings configBuilders="Environment">
<add name="MusicStoreEntities"
connectionString="ignored"
providerName="System.Data.SqlClient" />
</connectionStrings>
@sjwaight
sjwaight / sqlconnection.xml
Last active March 19, 2021 03:44
web.config snippet sample showing a SQL Connection String
<connectionStrings>
<add name="MusicStoreEntities"
connectionString="Server=myServerAddress;Database=myDataBase;User Id=myUsername;Password=myPassword;"
providerName="System.Data.SqlClient" />
</connectionStrings>
@sjwaight
sjwaight / createazuresqldb.sh
Created March 19, 2021 00:18
Sample script to create Azure SQL DB and show ADO.NET connection string
az group create --name {resgroup} --location {location}
az sql server create --admin-password {youradminpwd} --admin-user {youradminuser} --name {servername} --resource-group {resgroup} --location {location}
az sql db create --resource-group {resgroup} -server {servername} --name {dbname} --edition GeneralPurpose --family Gen5 --capacity 2 --compute-model Serverless
az sql db show-connection-string --server {servername} --name {dbname} -c ado.net
# Note that version numbers are applicable for .NET Framwork 4.7.2 and may differ from what your app requires
Install-Package Microsoft.AspNet.Mvc -Version 3.0.50813.1
Install-Package Microsoft.Configuration.ConfigurationBuilders.Environment -Version 2.0.0
Install-Package Microsoft.AspNet.Providers
@sjwaight
sjwaight / iobindingfunction.py
Last active October 28, 2020 23:36
Python Azure Function sample showing how to using Input and Output binding with Azure Blob Storage and doing local file manipulation.
from io import BytesIO
from logging import FileHandler
import logging
import azure.functions as func
from PIL import Image
def main(msg: func.QueueMessage, inputblob: func.InputStream,
outputblob: func.Out[func.InputStream]) -> None:
blob_source_raw_name = msg.get_body().decode('utf-8')