Install https://github.com/Microsoft/artifacts-credprovider
Add a nuget.config file to your project, in the same folder as your .csproj or .sln file. E.g.:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
[FunctionName("SbusQueueTriggerFunction")] | |
public async Task RunAsync( | |
[ServiceBusTrigger("%QueueName%", Connection = "SbusConnectionString")] | |
Message message, | |
MessageReceiver messageReceiver, | |
ILogger log) | |
{ | |
// ... | |
// dead-letter the msg |
using Microsoft.Azure.KeyVault.Models; | |
using Microsoft.Extensions.Configuration; | |
using Microsoft.Extensions.Configuration.AzureKeyVault; | |
namespace Demo.Azure.KeyVault | |
{ | |
public class PrefixKeyVaultSecretManager : IKeyVaultSecretManager | |
{ | |
private readonly string _prefix; |
configurationBuilder.AddAzureKeyVault(new AzureKeyVaultConfigurationOptions | |
{ | |
Vault = configuration["KeyVaultUrl"], | |
ReloadInterval = TimeSpan.FromMinutes(10), | |
Client = new KeyVaultClient(new KeyVaultClient.AuthenticationCallback( | |
new AzureServiceTokenProvider().KeyVaultTokenCallback)) | |
}); |
public static class ServiceExtensions | |
{ | |
public static IServiceCollection AddTypedHttpClient(this IServiceCollection service, IConfiguration configuration) | |
{ | |
service.Configure<HttpClientConfiguration>( | |
configuration.GetSection(nameof(HttpClientConfiguration))); | |
var provider = service.BuildServiceProvider(); | |
var httpConfiguration = provider.GetService<IOptions<HttpClientConfiguration>>().Value; |
Install https://github.com/Microsoft/artifacts-credprovider
Add a nuget.config file to your project, in the same folder as your .csproj or .sln file. E.g.:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
#!/bin/bash | |
set -euo pipefail | |
IFS=$'\n\t' | |
# -e: immediately exit if any command has a non-zero exit status | |
# -o: prevents errors in a pipeline from being masked | |
# IFS new value is less likely to cause confusing bugs when looping arrays or arguments (e.g. $@) | |
function usage() | |
{ |
# Set other app settings | |
$values = [System.IO.File]::ReadAllText($appSettings) | |
$appSettingsList = $values.Split([System.Environment]::NewLine) | |
echo "setting app settings: $appSettingsList" | |
az functionapp config appsettings set ` | |
--name $functionAppName ` | |
--resource-group $resourceGroup ` | |
--settings $appSettingsList |
builder.Services.Configure(delegate(ServiceBusOptions options) | |
{ | |
options.MessageHandlerOptions.AutoComplete = false; | |
}); |
# check to see if secret exists in keyvault, otherwise throw error | |
$SecretName = "HttpClientConfiguration--ApiKey" | |
$doesExist=$(az keyvault secret show ` | |
--vault-name $KeyVaultName ` | |
--name $SecretName ` | |
--query id -o tsv) | |
if ($doesExist) { | |
echo "Secret '$SecretName' found in vault '$KeyVaultName' OK" | |
} else { | |
echo "Expecting secret '$SecretName' to be in vault '$KeyVaultName'" |
public static class ServiceExtensions | |
{ | |
/// <summary> | |
/// Creates a custom configuration for easier development of Azure Functions. | |
/// When environment is not Development, it adds support for keyvault | |
/// </summary> | |
/// <param name="builder"></param> | |
/// <returns></returns> | |
public static IConfiguration GetCustomConfiguration(this IFunctionsHostBuilder builder) | |
{ |