private string GetBasePath()
{
var path = System.Diagnostics.Process.GetCurrentProcess()!.MainModule!.FileName;
FileInfo fi = new FileInfo(path);
// If you'd set something in a 'resources' folder and made the content copy always.
var basePath = fi.Directory + @"\resources\";
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From solution level: | |
containerRegistryName = The name of the container registry you create in Azure (acr) | |
acrRepositoryName = The individual repository within acr (e.g. my-microservice-app) | |
# Note build is from solution level. You might just need './Dockerfile .' | |
docker build -t {acrRepositoryName}:latest -f ./VsProjectName/Dockerfile . | |
az login | |
az acr login --name {containerRegistryName} | |
docker tag {acrRepositoryName}:latest {containerRegistryName}.azurecr.io/{acrRepositoryName}:latest; | |
docker push {containerRegistryName}.azurecr.io/{acrRepositoryName}:latest |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// See https://aka.ms/new-console-template for more information | |
using DoTaskAndGetResult; | |
Console.WriteLine("Hello, World!"); | |
TestClass tc = new TestClass(); | |
List<Task<TestData>> taskList = new List<Task<TestData>>(); | |
for(int i = 0; i < 1000; i++) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 0. Create Application insights (workspace version - You could set up a 'log analytics workspace' first) | |
// 1. In web app, Nuget -> Microsoft.ApplicationInsights.AspNetCore | |
// 2. Config (can either pass in app insights key, or use whole connection string in config) | |
// 3. (if using connectionstring, appsettings.json looks like) | |
//"ApplicationInsights": { | |
// "ConnectionString": "InstrumentationKey=...;IngestionEndpoint=https://...-0.in.applicati...ights.azure.com/;LiveEndpoint=https://........livediagnostics.monitor.azure.com/" | |
// }, | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Akka.Actor; | |
using AkkaHelloWorld; | |
Console.WriteLine("Enter a string to update the actor, or 'ask' to get its value"); | |
var system = ActorSystem.Create("MySystem"); | |
var greeter = system.ActorOf<SimpleMessageActor>("simplemsg"); | |
greeter.Tell(new SimpleMessage("Starting")); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.AspNetCore.Mvc; | |
namespace TestForAPIM.Controllers | |
{ | |
[ApiController] | |
[Route("[controller]")] | |
public class WeatherForecastController : ControllerBase | |
{ | |
private static readonly string[] Summaries = new[] | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$webAppObjectId = (Get-AzADServicePrincipal -DisplayName $webAppName).Id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Microsoft.Extensions.Caching.Memory; | |
using Microsoft.Extensions.Primitives; | |
using System; | |
namespace CacheTest | |
{ | |
public class CacheHelper | |
{ | |
private IMemoryCache _memoryCache { get; } = new MemoryCache( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void SendData(string authToken, MyDataClass myData) | |
{ | |
try | |
{ | |
var url = $"https://www.something.com/api/something/post"; | |
HttpClient client = new HttpClient(); | |
//client.BaseAddress = new Uri(url); | |
// Add an Accept header for JSON format. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#The command to delete all branches except master on linux is: | |
#git branch | grep -v "master" | xargs git branch -D | |
#To use the same command in Windows use powershell and CD to your repo | |
#Or, WINDOWS - we can use PowerShell command that do the same thing that above command do: | |
# Tried this and it worked nicely... | |
git branch | %{ $_.Trim() } | ?{ $_ -ne 'master' } | %{ git branch -D $_ } | |
#or WINDOWS - | |
#git branch -D @(git branch | select-string -NotMatch "master" | Foreach {$_.Line.Trim()}) |
NewerOlder