This file contains 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
var policy = HttpPolicyExtensions | |
.HandleTransientHttpError() | |
.RetryAsync(10, (ex, count) => | |
{ | |
Console.WriteLine($"Polly: error during call, retry n. {count}"); | |
}); | |
// this is an example of registering a typed client | |
services.AddHttpClient<WeatherClient>(h => | |
{ |
This file contains 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 registering a typed client | |
services.AddHttpClient<WeatherClient>(h => | |
{ | |
h.BaseAddress = new Uri("https://someOtherDomain.com/"); | |
}) | |
.ConfigurePrimaryHttpMessageHandler(sp => | |
(HttpMessageHandler)sp.GetService(MonoWasmHttpMessageHandlerType)); |
This file contains 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 WeatherClient | |
{ | |
private HttpClient _client; | |
public WeatherClient(HttpClient client) | |
{ | |
_client = client; | |
} | |
public async Task<WeatherForecast[]> GetForecastsAsync() |
This file contains 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 ConfigureServices(IServiceCollection services) | |
{ | |
// let's remove the current entry for HttpClient first | |
var httpSvc = services | |
.Single(x => x.ServiceType == typeof(HttpClient)); | |
services.Remove(httpSvc); | |
// we add the WasmHttpMessageHandler | |
Type MonoWasmHttpMessageHandlerType = Assembly.Load("WebAssembly.Net.Http") | |
.GetType("WebAssembly.Net.Http.HttpClient.WasmHttpMessageHandler"); |
This file contains 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
<ItemGroup> | |
<!-- other references here... --> | |
<PackageReference Include="Microsoft.Extensions.Http" Version="3.1.0-preview2.19525.4" /> | |
<PackageReference Include="Microsoft.Extensions.Http.Polly" Version="3.1.0-preview2.19525.4" /> | |
</ItemGroup> |
This file contains 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 MsalAuthenticationStateProvider : AuthenticationStateProvider | |
{ | |
// more code here | |
public async Task SignInAsync() | |
{ | |
await _js.InvokeVoidAsync("azuread.signIn"); | |
await AuthenticationChanged(); | |
} |
This file contains 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 MsalAuthenticationStateProvider : AuthenticationStateProvider | |
{ | |
private IJSRuntime _js; | |
public MsalAuthenticationStateProvider(IJSRuntime js) | |
{ | |
_js = js; | |
} | |
public async override Task<AuthenticationState> GetAuthenticationStateAsync() |
This file contains 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
function AzureAd() { | |
AzureAd.prototype.initialize = function (msalConfig) { | |
this.msalObj = new Msal.UserAgentApplication(msalConfig); | |
}; | |
AzureAd.prototype.signIn = function () { | |
return this.msalObj.loginPopup(); | |
}; | |
AzureAd.prototype.signOut = function () { |
This file contains 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
#Calculate date threshold | |
$threshold = (Get-Date).ToUniversalTime().AddDays(-30) | |
Write-Output "Deleting deployments older than $threshold" | |
#Get all deployments older than the threshold | |
$deployments = Get-AzureRmResourceGroup | ` | |
Get-AzureRmResourceGroupDeployment | ` | |
Where-Object{$_.Timestamp.Date -lt $threshold} |
This file contains 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
workflow Deployment-Cleanup-Wkf | |
{ | |
$connectionName = "AzureRunAsConnection" | |
try | |
{ | |
# Get the connection "AzureRunAsConnection " | |
$servicePrincipalConnection=Get-AutomationConnection -Name $connectionName | |
"Logging in to Azure..." | |
Add-AzureRmAccount ` |
NewerOlder