microsoft / Broadcast-Development-Kit

Tools for Broadcasters utilizing Teams
MIT License
58 stars 24 forks source link

How to add a DNS record pointing to ngrok's TCP Url. #20

Closed dmklementiev-zz closed 3 years ago

dmklementiev-zz commented 3 years ago

Have a question regarding adding a DNS record pointing to ngrok's TCP Url.

This document mentions that I have to add a DNS record pointing to ngrok's TCP Url while providing serviceFqdn.

Could you please explain how this should be done or point me to the right documentation?

Should I create a DNS zone in Azure and add a record pointing my domain to tcp.ngrok.io?

dmklementiev-zz commented 3 years ago

The reason I am asking is that when I start the solution - two browsers come up with error 404 for https://localhost:8442/ and https://localhost:9442/ (values are the same as in this document.

My understanding is that the browsers should have empty context rather than not found error - is this correct?

My DNS Record look like:

image

Ngrok:

image

and BotService appsettings.local.json:

image

Any help is appreciated. Thank you.

JonatanMedinilla commented 3 years ago

Hi @dmklementiev, regarding the DNS configuration this is the original documentation we followed to run an application hosted media bot for the first time. Azure DNS is not an exclusive requirement, so you can use a platform of your choice. From what I could see in your comment, you've correctly added the DNS record.

With respect to the browsers that come up when you start the solution you should ignore that behavior, but if it is annoying, you can override that behavior by changing the launchBrowser setting to false, in the Management API and Bot Service launchSettings.json.

Despite that, did you have any issues running the solution locally?

dmklementiev-zz commented 3 years ago

Thank you Jonatan for your prompt response. Yes, I have one more issue running locally at the last step. When I POST meeting link in Postman I am getting the following response.

{ "value": { "stackTrace": " at Microsoft.Graph.Communications.Client.Transport.GraphClientWrapper.<ValidateAndWrapAsync>d__121.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Graph.Communications.Client.Transport.GraphClientWrapper.d112.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Graph.Communications.Resources.StatefulResourceCollection4.d26.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Graph.Communications.Calls.StatefulCallCollection.d9.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Graph.Communications.Resources.StatefulResourceCollection`4.d31.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.Graph.Communications.Resources.StatefulResourceCollection4.<GenerateStatefulResourceAsync>d__22.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1.ConfiguredTaskAwaiter.GetResult()\r\n at BotService.Infrastructure.Core.Bot.d19.MoveNext() in C:\TeamsBDK\Broadcast-Development-Kit\src\BotService\Infrastructure\Core\Bot.cs:line 92\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.GetResult()\r\n at Application.Service.Commands.InviteBot.InviteBotCommandHandler.d2.MoveNext() in C:\TeamsBDK\Broadcast-Development-Kit\src\Application\Service\Commands\InviteBot.cs:line 51\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter1.GetResult()\r\n at Application.Common.ValidationBehaviour2.d2.MoveNext() in C:\TeamsBDK\Broadcast-Development-Kit\src\Application\Common\ValidationBehaviour.cs:line 38\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.d2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at MediatR.Pipeline.RequestExceptionProcessorBehavior2.<Handle>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at MediatR.Pipeline.RequestExceptionActionProcessorBehavior2.d2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.d2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at MediatR.Pipeline.RequestPostProcessorBehavior2.<Handle>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at MediatR.Pipeline.RequestPreProcessorBehavior2.d2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()\r\n at BotService.Controllers.BotController.d4.MoveNext() in C:\TeamsBDK\Broadcast-Development-Kit\src\BotService\Controllers\BotController.cs:line 39\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.AspNetCore.Mvc.Internal.ActionMethodExecutor.TaskOfIActionResultExecutor.d0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d12.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d10.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.d13.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d23.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Rethrow(ResourceExecutedContext context)\r\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)\r\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d18.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.d16.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.AspNetCore.Builder.RouterMiddleware.d4.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.d__6.MoveNext()", "innerException": "Code: clientCallbackError\r\nMessage: Unexpected exception happened on client when authenticating request.\r\n", "identifier": "92c2e9a2-5753-4c1b-a5a2-3a1571455c09", "type": "https://tools.ietf.org/html/rfc7231#section-6.6.1", "title": "An error ocurred while trying to communicate with Graph API", "status": 500, "detail": "Unexpected exception happened on client when authenticating request.\r\nScenario Id: 6aea2127-f59c-4e76-b303-011aeb99479b", "extensions": {} }, "formatters": [], "contentTypes": [], "declaredType": "Infrastructure.Core.Common.Models.ErrorDetails, Infrastructure.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", "statusCode": 500 }`

I haven't had a deep investigation on this yet. It seems that authentication for MSGraph is failing with AAD. Not sure why though, so if you could suggest what the cause is that would be great.

dmklementiev-zz commented 3 years ago

Did a bit more investigation and here is what I see in the logs (actually "var logString = _formatter.Format(logEvent)" value in SampleObserver.cs)

$>2021-08-23T22:30:55.1627070Z Error: AuthenticationProvider.cs:95 AuthenticateOutboundRequestAsync ScenarioId: 2f4eb22f-8365-4352-975f-f038ffef2eff Failed to generate token for client: 3e534d8c-**** exception: AADSTS700016: Application with identifier '3e534d8c-****' was not found in the directory '72f988bf-*****'. This can happen if the application has not been installed by the administrator of the tenant or consented to by any user in the tenant. You may have sent your authentication request to the wrong tenant. Trace ID: 682a364f-f934-4f34-8ab8-e991938c0a00 Correlation ID: d74a7505-5267-4146-aae5-e78405ab298c Timestamp: 2021-08-23 22:30:55Z Response status code does not indicate success: 400 (BadRequest).

What is interesting is that '3e534d8c-**' is correct clientId for Bot application in AAD, but '72f988bf-***' is a random tenant and its value is not found in any configuration files. Have to say that I can recognize this tenantId which comes to play from totally unrelated project. Investigating further, but if you have any ideas how it gets to the BDK execution, please let me know.

JonatanMedinilla commented 3 years ago

@dmklementiev Have you created the app registration (for the Azure Bot) in the same tenant where you have Microsoft Teams?

dmklementiev-zz commented 3 years ago

Yes, however, I created a meeting in a different tenant, which I think is the problem since tenant id is a part of meeting link. I will try creating a meeting in the correct tenant and reply here with the result. Thank you!!!

dcherubini commented 3 years ago

@dmklementiev Were you able to test this again in the correct tenant?

dmklementiev-zz commented 3 years ago

Yes, sorry for the delay - it took me some time to set up Teams in the tenant properly. Running locally works now. Will try other/more advanced scenarios. Likely will have more questions :) Thanks a lot for your help.

HaoTao95 commented 3 years ago

@dmklementiev, Could you let me know how to set up Teams in the tenant?

HaoTao95 commented 3 years ago

Have you created the app registration (for the Azure Bot) in the same tenant where you have Microsoft Teams?

can you let me know this way? Thanks

dmklementiev-zz commented 3 years ago

@HaoTao95 - not sure if you are commenting on this issue (it is resolved) or the most recent one I opened .. In any case Azure Bot is created in the same tenant where I have MS Teams. Is there anything else I can check?

Also should we continue discussion here or in https://github.com/microsoft/Broadcast-Development-Kit/issues/34?

Thank you.

HaoTao95 commented 3 years ago

@dmklementiev Have you created the app registration (for the Azure Bot) in the same tenant where you have Microsoft Teams?

Hi @JonatanMedinilla, could you explain about this?

HaoTao95 commented 3 years ago

@dmklementiev , can you explain me how to create Azure Bot in the same tenant where I have MS Teams?

dmklementiev-zz commented 3 years ago

@HaoTao95, first off I am not an expert in this project. I am rather just beginning to understand how it works. To answer your question - I can only tell you how I did this. I registered Azure Bot as described in this document.