Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Bayological bayological

🎯
Focusing
View GitHub Profile
View Update release pipeline variable.ps1
$url = "$($env:SYSTEM_TEAMFOUNDATIONCOLLECTIONURI)$env:SYSTEM_TEAMPROJECTID/_apis/Release/definitions/$($env:RELEASE_DEFINITIONID)?api-version=5.0"
#Get definition
$pipeline = Invoke-RestMethod -Uri $url -Headers @{
Authorization = "Bearer $env:SYSTEM_ACCESSTOKEN"
}
#Update variable
$pipeline.variables.MyVariableName.value = "New value"
@bayological
bayological / CreateResourceGroupAndSites
Created Jul 8, 2019
Create resource group, app service & website
View CreateResourceGroupAndSites
public static async Task Main(string[] args)
{
string _location = "West Europe";
TokenCredentials credentials = await GetTokenCredentialsAsync().ConfigureAwait(false);
var _webClient = new WebSiteManagementClient(credentials)
{
SubscriptionId = _subscriptionId
};
View GetAzureAuthToken.cs
private static async Task<TokenCredentials> GetTokenCredentialsAsync()
{
var clientCredential = new ClientCredential(_clientId, _clientSecret);
var authContext = new AuthenticationContext($"https://login.windows.net/{_tenantId}");
AuthenticationResult result;
try
{
result = await authContext.AcquireTokenAsync("https://management.azure.com/", clientCredential).ConfigureAwait(false);
@bayological
bayological / AzureCreds.cs
Created Apr 8, 2019
Azure credential variables
View AzureCreds.cs
private static string _subscriptionId = "";
private static string _clientId = "";
private static string _clientSecret = "";
private static string _tenantId = "";
@bayological
bayological / gist:801b184dbda862d8c3e9613db353599f
Created Oct 1, 2018
Publishing a self contained .Net Core app targeting Windows x64
View gist:801b184dbda862d8c3e9613db353599f
dotnet publish --runtime win10-x64 -o C:\TestPublish -f netcoreapp2.0 -c debug
@bayological
bayological / RegistrationsInNamespace.cs
Created Sep 28, 2018
Registration of classes in the same namespace as ICat
View RegistrationsInNamespace.cs
public static void Run(IServiceCollection services)
{
services.Scan(scan => scan
.FromAssemblyOf<ICat>()
.AddClasses(classes => classes.InNamespaceOf<ICat>())
.AsImplementedInterfaces()
.WithTransientLifetime());
services.AddSingleton<IApplication, Application>();
}
@bayological
bayological / registration.cs
Created Sep 28, 2018
Type registration with Scurtor
View registration.cs
public static void Run(IServiceCollection services)
{
services.Scan(scan => scan
.FromAssemblyOf<ICat>()
.AddClasses()
.AsImplementedInterfaces()
.WithTransientLifetime());
services.AddSingleton<IApplication, Application>();
}
@bayological
bayological / registrations.cs
Created Sep 28, 2018
Registering types manually without Scrutor
View registrations.cs
services.AddTransient<ICow, Cow>();
services.AddTransient<IMouse, Mouse>();
services.AddTransient<ICat, Cat>();
@bayological
bayological / speak.cs
Last active Sep 28, 2018
Speaking animals work method
View speak.cs
private async Task WorkAsync()
{
while (true)
{
Console.WriteLine("The animals will now speak...");
_cow.Speak();
_cat.Speak();
_mouse.Speak();
Thread.Sleep(TimeSpan.FromSeconds(3));
}
@bayological
bayological / application.cs
Last active Sep 28, 2018
Application class with animal types
View application.cs
public class Application : IApplication
{
private readonly ICat _cat;
private readonly ICow _cow;
private readonly IMouse _mouse;
public Application(ICat cat, ICow cow, IMouse mouse)
{
_cat = cat;
_mouse = mouse;