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
// This is an example of using the Aspire Interaction service to prompt users | |
// to install a missing dependencies if it's not present. | |
// | |
// Ideally you can get all your dependencies through `dotnet restore`, or other package mangers that run as part of your app host, | |
// but that may not be possible, particularly if third parties don't provide package manager friendly setup. | |
// | |
// `Helper.IsInstalled()` and `Helper.Install()` implementations are not included and will vary based on your dependency | |
public static T WithDependencyInstaller<T>(this T builder) | |
where T : IDistributedApplicationBuilder |
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
// Define our initial value | |
var value = "initial value"; | |
resource | |
// Important - need to use a lambda here to ensure the latest value is loaded when the app is restarted | |
.WithEnvironment("Dynamic", () => value) | |
// Add a custom command, when invoked, this | |
// 1. uses the interaction service to prompt for a value | |
// 2. Update the value used in the `WithEnvironment` lambda | |
// 3. Restarts the resource to force it to pick up the new env var. |
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 record class ConfigFileContext( | |
DistributedApplicationModel AppModel, | |
Stream Stream, | |
CancellationToken CancellationToken | |
); | |
[DebuggerDisplay($"{{{nameof(Path)},nq}}")] | |
public class ConfigFileAnnotation(string path, Func<ConfigFileContext, Task> generator) : IResourceAnnotation | |
{ | |
public FileInfo Path { get; } = new FileInfo(path); |
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 class DelayStartAnnotation(IResource waitForResource) : IResourceAnnotation | |
{ | |
public IResource WaitForResource { get; } = waitForResource; | |
} |
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 class BackgroundRefreshableCache<TKey, TValue> | |
{ | |
public TimeSpan RefreshInterval { get; } | |
private readonly Func<TKey, Task<TValue>> _loader; | |
private ImmutableDictionary<TKey, Task<TValue>> _cache = ImmutableDictionary<TKey, Task<TValue>>.Empty; | |
public BackgroundRefreshableCache(Func<TKey, Task<TValue>> loader) | |
{ | |
_loader = loader; | |
} |
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 System; | |
using System.Collections.Generic; | |
using System.Threading.Tasks; | |
using Microsoft.Azure.Documents; | |
using Microsoft.Azure.Documents.Client; | |
namespace Cosmos | |
{ | |
class Program | |
{ |
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
// If you run the following with the cosmos emulator disabled, it takes about 2 minutes before the OpenAsync call fails | |
// Comment out the SetLocation line, and it takes about 8. | |
using System; | |
using System.Diagnostics; | |
using System.Threading.Tasks; | |
using Microsoft.Azure.Documents.Client; | |
namespace CosmosTimeoutTest | |
{ |
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 NUnit.Framework; | |
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
namespace BackgroundRefreshable | |
{ | |
///<summary> | |
/// Provides support for loading, storing and refreshing a value asyncronously. | |
/// |
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
#Requires -Version 3.0 | |
<# | |
.Description | |
Installs Apache Solr | |
.Example | |
.\ServiceInstall.ps1 | |
Installs Apache Solr as the 'solr' service running on port 8983. | |
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
#This script calculates how many PRs each person merged | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$PersonalAccessToken, | |
[Parameter(Mandatory=$true)] | |
[string]$OrgOrUser, | |
[Parameter(Mandatory=$true)] | |
[string]$RepoName | |
) | |
$base64Token = [Convert]::ToBase64String([char[]]$PersonalAccessToken) |
NewerOlder