Unable to set MicrosoftAppPassword value in azure function V3
See original GitHub issueI’m trying to set MicrosoftAppPassword in azure function but no success.
I have created ConfigurationCredentialProvider class and inlcuded in Startup.cs
internal class ConfigurationCredentialProvider : SimpleCredentialProvider
{
public ConfigurationCredentialProvider(IConfiguration configuration)
{
this.Password = "App password here";
}
}
public class Startup : FunctionsStartup
{
public override void Configure(IFunctionsHostBuilder builder)
{
var config = new ConfigurationBuilder()
.AddEnvironmentVariables()
.Build();
// Set up the dependency injection container
var serviceCollection = builder.Services;
serviceCollection.AddSingleton<ICredentialProvider, ConfigurationCredentialProvider>();
}
}
I always get this exception
Exception while executing function: BotMessagesHandler <--- Value cannot be null. (Parameter 'clientSecret')
If i add key ‘MicrosoftAppPassword’ in local.settings.json then Bot automatically pick app password from json
Issue Analytics
- State:
- Created 3 years ago
- Comments:21 (2 by maintainers)
Top Results From Across the Web
Troubleshooting Bot Framework Authentication - Bot Service
Learn how to troubleshoot bot authentication errors, such as connectivity issues and problems with app IDs and passwords.
Read more >Getting error "Failed to decrypt settings..." when trying to ...
We have a bot endpoint implemented as an Azure function and it's running fine within Azure. We've followed this process to enable us...
Read more >Can't create v3 Function project - Developer Community
Go back to creating a new project but select Azure Functions v2. The message 'Making sure all templates are up to date...' shows....
Read more >Unauthorized: Logon failed due to server configuration. " I can ...
Azure functions app keeps returning 401 unauthorized. all" permission. ... Solution 3: Delete & Create new App Registration When trying to hit the...
Read more >Azure Function Alert on Failure: A Comprehensive guide
Are you missing out on notifications when there is an Azure Function failure? Read our detailed guide on how to create an alert...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hello @atifgk!
I just found your code and see what is going on here. You are using
AdapterWithErrorHandler
which does not receive anICredentialProvider
in the constructor. So even if you are registering yourConfigurationCredentialProvider
in your startup, it will never picked up by any class because no class that you are using expects aICredentialProvider
constructor parameter.The solution is to modify your
AdapterWithErrorHandler
to receive theICredentialProvider
and pass it to the base class during constructor. This sample implements anAdapterWithErrorHandler
that does exactly that. It is not in a functions environment, but the only thing you should take from it is adding the ICredentialProvider parameter to your AdapterWithErrorHandler constructor and then call: base(credentialProvider)
.On a separate note, the Bot Framework SDK already has a
ConfigurationCredentialProvider
class, so I’d suggest you create a new class with a name such asKeyVaultCredentialProvider
for your custom provider. Also consider if you need to inherit fromSimpleCredentialProvider
like you did in the snippet above. If you do not need anything from that class, I’d have yourKeyVaultCredentialProvider
directly implement the interfaceICredentialProvider
.Please let me know if that doesn’t work or if you have questions. I’m very sorry that you had to wait a bit to get this resolved, hopefully we can make it up to you in the future. Also I’m glad you are using functions, I think they are a great way to hosting bots.
@carlosscastro @dmvtech thanks. implenting !CredentialProvider worked