Skip to content

Instantly share code, notes, and snippets.

View subhankars's full-sized avatar

Subhankar Sarkar subhankars

View GitHub Profile
#This is a Build Deploy Pipeline for .NET 6 Web App to Azure App Service using Azure DevOps Pipeline
trigger:
- master
pool:
vmImage: ubuntu-latest
variables:
buildConfiguration: 'Release'
trigger:
- main
pool:
vmImage: ubuntu-latest
steps:
- checkout: self
submodules: true
- task: AzureStaticWebApp@0
@subhankars
subhankars / AzureAuthHelper.cs
Last active July 6, 2022 07:23
Azure Blob Versioning
using System;
using System.Collections.Specialized;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Security.Cryptography;
using System.Text;
using System.Web;
namespace StorageRestApiAuth
@subhankars
subhankars / program.cs
Last active July 20, 2019 16:53
WebJob Program.cs
builder.ConfigureAppConfiguration((hostingContext, config) =>
{
var environmentName = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT");
Console.WriteLine("Environment Variable: " + environmentName);
var env = hostingContext.HostingEnvironment;
Console.WriteLine("hostingContext.HostingEnvironment: " + env.EnvironmentName);
config.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile($"appsettings.json", optional: true, reloadOnChange: true)
.AddJsonFile($"appsettings.{environmentName}.json", optional: true, reloadOnChange: true)
@subhankars
subhankars / deploywebjob-publishprofile.ps1
Created July 20, 2019 06:42
.NET Core WebJob Deploy with Powershell
#Zipped artifact path - get the path from Azure DevOps Pipeline variables
$path = "$(System.DefaultWorkingDirectory)\$($env:zippedArtifactPath)"
#Test the path if exists
if (-not (Test-Path $path))
{
throw [System.IO.FileNotFoundException] "$($path) not found."
}
#Resource type and details
@subhankars
subhankars / deploywebjob-basicauth.ps1
Last active December 13, 2019 13:17
Dotnet Core Webjob deployment
#Zipped artifact path - get the path from Azure DevOps Pipeline variables
$path = "$(System.DefaultWorkingDirectory)\$($env:zippedArtifactPath)"
#Test the path if exists
if (-not (Test-Path $path))
{
throw [System.IO.FileNotFoundException] "$($path) not found."
}
#Resource type and details
$resourceType = "Microsoft.Web/sites/config"
@subhankars
subhankars / Dockerfile
Created June 17, 2019 14:22
Dockerfile
FROM mcr.microsoft.com/dotnet/core/sdk:2.2 AS build-env
WORKDIR /app
# Copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore
# Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
@subhankars
subhankars / CustomEvent.cs
Last active July 6, 2022 07:22
Microsoft Azure EventGrid
using System;
namespace EventGridEventTrigger.Library
{
public static class CustomEvent<T>
{
public static EventGridEvent CreateCustomEvent(T obj)
{
return new EventGridEvent()
{