Skip to content

Instantly share code, notes, and snippets.

View bogdanbujdea's full-sized avatar
💭
Who reads this?

Bogdan Bujdea bogdanbujdea

💭
Who reads this?
View GitHub Profile
@bogdanbujdea
bogdanbujdea / StartContainer.cs
Last active September 28, 2018 09:17
Start an Azure Container Instance
private void RunTaskBasedContainer(IAzure azure,
string resourceGroupName,
string containerGroupName,
string containerImage)
{
IResourceGroup resGroup = azure.ResourceGroups.GetByName(resourceGroupName);
Region azureRegion = resGroup.Region;
var chartsJson = JsonConvert.SerializeObject(MarketCharts, Formatting.None, new JsonSerializerSettings { ContractResolver = new CamelCasePropertyNamesContractResolver() });
azure.ContainerGroups.Define(containerGroupName)
@bogdanbujdea
bogdanbujdea / CreateResourceGroup.cs
Last active September 28, 2018 10:10
Create Azure resource group
private void CreateResourceGroup(IAzure azure, string resourceGroupName, Region azureRegion)
{
azure.ResourceGroups.Define(resourceGroupName)
.WithRegion(azureRegion)
.Create();
}
@bogdanbujdea
bogdanbujdea / DeleteResourceGroup.cs
Created September 28, 2018 10:11
Delete Azure resource group
private void DeleteResourceGroup(IAzure azure, string resourceGroupName)
{
azure.ResourceGroups.DeleteByNameAsync(resourceGroupName);
}
@bogdanbujdea
bogdanbujdea / StopContainerGroup.cs
Created September 28, 2018 10:24
Stop a container group
private void StopContainerGroup()
{
IAzure azure = GetAzureContext(Environment.GetEnvironmentVariable(AzureLoginPath));
var containerGroup = azure.ContainerGroups.GetByResourceGroup(ResourceGroupName, ContainerGroupName);
//this will stop all the containers in that group, and billing will stop
containerGroup?.Stop();
}
@bogdanbujdea
bogdanbujdea / msbuild-tools.json
Created February 1, 2019 12:12
Settings for running COM add-in inside VS Code
{
"solution": "${workspaceRoot}/SOLUTION_NAME.sln",
"variables": {
"MSBUILD": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/MSBuild/15.0/Bin/MSBuild.exe",
"DEVENV": "C:/Program Files (x86)/Microsoft Visual Studio/2017/Enterprise/Common7/IDE/devenv.com"
},
"buildConfigurations": [
"Debug",
"Release"
],
@bogdanbujdea
bogdanbujdea / Dockerfile
Created February 22, 2019 09:53
Sample dockerfile with only one stage
FROM microsoft/dotnet AS build-env
COPY . /app
RUN ["dotnet", "--info"]
WORKDIR /app/MyApp
RUN ["dotnet", "publish", "--configuration", "Release"]
@bogdanbujdea
bogdanbujdea / install.sh
Created March 5, 2019 17:50
Install dotnet sdk 2.2 in WSL
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/microsoft-ubuntu-bionic-prod bionic main" > /etc/apt/sources.list.d/dotnetdev.list'
sudo apt-get install apt-transport-https
sudo apt-get update
sudo apt-get install dotnet-sdk-2.2
@bogdanbujdea
bogdanbujdea / file-sort.csproj
Last active March 11, 2019 21:36
csproj file for file-sort, a dotnet global tool
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<IsPackable>true</IsPackable>
<PackAsTool>true</PackAsTool>
<ToolCommandName>file-sort</ToolCommandName>
<Version>1.0.1</Version>
<PackageOutputPath>./nupkg</PackageOutputPath>
<TargetFramework>netcoreapp2.1</TargetFramework>
@bogdanbujdea
bogdanbujdea / CustomAction.cs
Created March 11, 2019 16:49
Redirecting bindings in a Wix CustomAction
[CustomAction]
public static ActionResult UpdateBindingRedirects(Session session)
{
var doc = new XDocument();
doc.Load("...configPath");
var bindings = @"<assemblyBinding xmlns=""urn:schemas-microsoft-com:asm.v1"">
<dependentAssembly>
<assemblyIdentity name=""Newtonsoft.Json"" publicKeyToken=""30ad4fe6b2a6aeed"" culture=""neutral"" />
<bindingRedirect oldVersion=""0.0.0.0-12.0.1.0"" newVersion=""12.0.1.0"" />
</dependentAssembly>
@bogdanbujdea
bogdanbujdea / Program.cs
Created April 8, 2019 20:41
Using ExecuteAsync in dotnet global tool
class Program
{
public static async Task Main(string[] args)
=> await CommandLineApplication.ExecuteAsync<Program>(args);
private async Task OnExecute()
{
await Something();
}
}