Skip to content

Instantly share code, notes, and snippets.

View spboyer's full-sized avatar
💭
Coding, contributing, supporting, mentoring, learning, all of the right verbs

Shayne Boyer spboyer

💭
Coding, contributing, supporting, mentoring, learning, all of the right verbs
View GitHub Profile
@spboyer
spboyer / gen.bicep
Created August 22, 2022 18:15
Bicep File Generated by Bicep Extension - .NET API
@description('Generated from /subscriptions/<mysubid>/resourceGroups/dotnetazdsample-rg/providers/Microsoft.Web/sites/app-api-us4wfunnnezqy')
resource appapiuswfunnnezqy 'Microsoft.Web/sites@2022-03-01' = {
name: 'app-api-us4wfunnnezqy'
kind: 'app'
location: 'South Central US'
tags: {
'azd-env-name': 'dotnetazdsample'
'azd-service-name': 'api'
}
@spboyer
spboyer / dotnetcore_docker_k8s.md
Last active November 9, 2019 14:55
.NET Core Microservices, Docker, Kubernetes demo script

Simplest Microservice

File > New Project > Empty Web

  • This shows the minimal microservices that .NET Core offers, receiving a request, returning a route.
  • We have found that when talking to customers that they were building APIs having MVC was more than needed. The "V" was unused, the folder structure may have not made sense etc.
  • Talk to Endpoint Routing
  • Add Health Check - speak to the built in capabilities if Docker and K8s looking for a health endpoint and acting on fail/success
@spboyer
spboyer / dotnetconf.md
Created September 23, 2019 16:55
dotnetconf script
dotnet new worker -o worker
cd worker
code-insiders .
  • Add Dockerfile
az acr build -t workersidecar1:latest -r shayne .
@spboyer
spboyer / Program.cs
Created June 7, 2019 20:27
Basic ASP.NET Core Program.cs file
public class Program
{
public static void Main(string[] args)
{
CreateWebHostBuilder(args).Build().Run();
}
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>();
@spboyer
spboyer / aspnetcore.service.yaml
Created June 7, 2019 20:25
Helm Deployment and Service example for aspnetcore
apiVersion: apps/v1
kind: Deployment
metadata:
name: apiservice
labels:
app: apiservice
spec:
replicas: 1
template:
metadata:
@spboyer
spboyer / .bashrc
Created January 25, 2019 22:49
bashrc scripts
function dockerstopall {
echo ’stopping all containers’;
docker stop $(docker ps -a -q);
}
function dockerremoveallcontainers {
echo ‘removing all containers’;
docker rm $(docker ps -a -q);
}
@spboyer
spboyer / azure-cdn-image-error.js
Created August 17, 2018 14:30
Azure CDN Image Tag Helper Error Handling
//Retrieve any existing onerror handler code
var onError = output.Attributes[OnErrorAttributeName] ? .Value as string;
//Check if there's a fallback source and no onerror handler
if (!string.IsNullOrWhiteSpace(FallbackSrc) && string.IsNullOrWhiteSpace(onError)) {
string resolvedUrl;
if (TryResolveUrl(FallbackSrc, out resolvedUrl)) {
FallbackSrc = resolvedUrl;
}
if (AppendVersion) {
FallbackSrc = _fileVersionProvider.AddFileVersionToPath(FallbackSrc);
@spboyer
spboyer / cdnimage-taghelper.cs
Created August 17, 2018 14:28
azure cdn image tag helper
if (AppendVersion)
{
EnsureFileVersionProvider();
Src = output.Attributes[SrcAttributeName].Value as string;
// Check if the CDN Base URI is set and add to the src attribute
if (!string.IsNullOrWhiteSpace(CdnUri))
{
output.Attributes.SetAttribute(SrcAttributeName, string.Format("{0}{1}", CdnUri, _fileVersionProvider.AddFileVersionToPath(Src)));
}
}
@spboyer
spboyer / azure-gulp.js
Created August 17, 2018 14:24
Gulp task to push images to Azure CDN
var azure = require('gulp-azure-storage');
gulp.task("pushimages", function() {
return gulp.src("wwwroot/images/**").pipe(azure.upload({
account: process.env.ACCOUNT_NAME,
key: process.env.ACCOUNT_KEY,
container: process.env.CONTAINER_NAME
}));
});
@spboyer
spboyer / cdn_cache_thing.cs
Created August 11, 2018 15:45
serverless-cdn script
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.WindowsAzure.Storage.Blob;
namespace Workshop.Function