azure chatbot not working. after publishing from visual studio(2017) - c#

i done the following steps:
created web app bot (bot framework sdk v4) and perform 'test web chat'. which is successful and the bot responded.
note: Microsoft app id and password are created.
Downloaded the code.
updated bot file(.bot) with luis and qna configuration manually
#{
"appId": "XXXXXXX",
"authoringKey": "xxxxxxxxxx",
"version": "0.1",
"region": "xxxxx",
"type": "luis",
"name": "BasicBotLuisApplication",
"id": "6"
#}
#{
"appId": "XXXXXXX",
"authoringKey": "xxxxxxxxxx",
"version": "0.1",
"region": "xxxxx",
"type": "qna",
"name": "myqna"
#}
and put 'Padlock' with empty value
Also updated the code (Startup.cs,BotServices.cs) and build app locally.
For testing locally,used bot framework emulator and which was successful.
Then 'Publish' the application with visual studio.
Try to connect with 'Test webchat'. The operation failed and received error code(401 and 403).
what shall do? any solutions?

401 is unauthorized so did you make sure your file containing your authorization key got published?
If the file is not part of your solution/project it will not get deployed. Make sure that file is available post deployment on your app service (I presume?), you can use Kudu by going to [AppServiceName].scm.azurewebsites.net
Use the Debug Console to verify the file.

You need to look at your authentication. Usually, there should be some sort of session ID token that your browser session caches after authentication. From what you told us, there doesn't seem to be an authentication step.

Related

vscode c# debugger was not attached within the expected time limit

I'm running vscode version 1.73.1
I have the following extensions installed on a new VM that sits behind a corporate proxy:
Microsoft C# v1.25.2
Azurite v3.20.1
Azure Functions v1.9.0
I have a C# Azure Functions project that I'd like to debug.
My tasks.json file contains the following:
{
"type": "func",
"dependsOn": "build (functions)",
"options": {
"cwd": "${workspaceFolder}/bin/Debug/net6.0"
},
"command": "host start --dotnet-isolated-debug",
"isBackground": true,
"problemMatcher": "$func-dotnet-watch"
}
The launch.json is as follows:
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to .NET Functions",
"type": "coreclr",
"request": "attach",
"processId": "${command:azureFunctions.pickProcess}"
}
]
}
I click the debug icon from the sidebar menu and choose "Run and Debug - Attach to .Net Functions"
The function app is then build and starts. The VM is slow so it takes more than 60 seconds for the function app to start. During that time VS code pops up a message to say is it slow. However, the function app does start and the http endpoints are presented in green text.
I then see the following presented in the terminal window:
Azure Functions .NET Worker (PID: 12116) initialized in debug mode.
Waiting for debugger to attach... Host lock lease acquired by instance
ID '00000000000000000000000083B41702'. A debugger was not attached
within the expected time limit. The process will continue without a
debugger. Worker process started and initialized.
I don't see any text in the "Debug Console"
I am able to call the http endpoint and a successful response is returned, but the breakpoint does not break!
If I run the same solution in vs code directly on my laptop, then the debugger is attached. Problem is, I need to debug on the corporate VM because the code selects from an on-prem sql db.
So, I guess there must be some difference between the two configurations of vs code / extensions or perhaps the corporate proxy is causing a problem?
Not sure which text file this gets saved to but was able to resolve by extending the timeout in the workspace preferences section:
I increased from the default of 60 (seconds) to 180

Testing with emulator - Can't get response from bot when running from publish directory

When i build and run the project everything works fine.
When i publish the project and run it from within publish directory, it doesn't respond to any message.
In the emulator i get the message:
Cannot post activity. Unauthorized.
POST403 directline.postActivity
dotnet myBot.dll //from within publish directory, bot runs, doesnt repond to any message
dotnet run //from project directory, everything works fine
So, the problem was that i was tying to test production configuration trough localhost endpoint and in my .bot file i had this:
{
"type": "endpoint",
"appId": "myId",
"appPassword": "myPass",
"endpoint": "https://my.azurewebsites.net/api/messages",
"name": "production",
"id": "4"
},
The production endpoint is the azure service. So, you either test locally on localhost or set your service on Azure to point to your localhost(ngrok provided link - In that case you need to configure ngrok to expose your localhost to the outside).
https://blog.botframework.com/2017/10/19/debug-channel-locally-using-ngrok/

Missing heroku worker dyno

I'v been recently trying to experience with Heroku, to host a c# (Console application) Discord.Net (API) project.
I deployed the entire project using the Heroku CI and then added the Procfile and the package.json with
$git commit
and it responded with "nothing added to commit but untracked files present."
With that I went to the site only to find out that my Worker Dyno that I declared on my profile is missing.
Can someone help me figure out why is the Dyno missing although I declared it?
Procfile:
worker: node Program.cs //The file containing the script
Package:
{
"name": "Test",
"description": "Test",
"version": "0.0.0",
"main": "Program.cs",
"scripts": {
"start": "node Program.cs"
},
"dependencies": {
"discord.net": "1.0.2"
}
}
The procfile MUST'NT contain any extensions... the debugger misses it otherwise.
Unlike the explenation that heroku provides...
Once I removed all extensions it was recognized as a dyno.

Some file not served when run via Visual Studio Code

I have a 'Hello World' Kestrel server generated by Yeoman (as described here).
yo aspnet
When I run the site via the command line everything work well:
dotnet run
If it's run through Visual Studio Code though bootstrap.css, jquery.js and bootstrap.js don't load (404).
Looking at the F12 tools, they are actually coming from different locations. When run via dotnet run they come from https://ajax.aspnetcdn.com/..., but when run through Visual Studio Code the browser is looking for them in a local folder ~/lib/....
a. Why are the files being sourced differently depending on how I run the site?
b. How do I fix this?
Thanks
When you run it from command line, it runs in production mode (no ASPNETCORE_ENVIRONMENT variable set. When you run it from Visual Studio it sets the ASPNETCORE_ENVIRONMENT to Development.
Inside your Razor files, you have a <environments> section which controls which files are served in which production mode. Depending on your environment/OS, you need to set the variable differently. i.e. in Linux you'd need to run ASPNETCORE_ENVIRONMENT=Development dotnet run.
As for the reason why you get 404 when running in development mode, you probably need to copy over the wwwroot folder to your output directory, with this entry in your project.json.
"buildOptions": {
"emitEntryPoint": true,
"preserveCompilationContext": true,
"copyToOutput":
[
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
"publishOptions": {
"include": [
"wwwroot",
"Views",
"appsettings.json",
"web.config"
]
},
Though usually it should be necessary to add wwwroot to copyToOutput

ASP.NET 5 Kestrel connect within LAN

I would like to connect to my Kestrel server with ASP.NET 5 application hosted on it from another PC in the same network. Is it possible? I can ping my computer from cmd, but I get 'Connection timed out' when I try to connect from a web browser (I type this: "http://{my_kestrel_ip}:5000/").
The hosting.ini was not working for us. I have to add this to the project.json file. I believe that the hosting.ini file is being deprecated after Beta8.
--server.urls http://0.0.0.0:5000
or I prefer the following which I believe is less confusing.
--server.urls http://*:5000
So you would end up with something like this in your project.json.
"commands": {
"web": "Microsoft.AspNet.Hosting --server Microsoft.AspNet.Server.Kestrel --server.urls http://0.0.0.0:5000",
"ef": "EntityFramework.Commands"
},
In your project folder you should have a file called hosting.ini. In that file by default you should have something like this:
server=Kestrel
server.urls=http://localhost:5000
You need to make the HTTP server listen on your public IP address as well as localhost. To do that, you can add an additional address by separating them with a semi colon:
server.urls=http://localhost:5000;http://{my_kestrel_ip}:5000
Just did a quick test that seems to work.
Create a hosting.json file beside your project.json file.
hosting.json:
{
"server.urls": "http://localhost:5000;http://192.168.1.4:5000"
}
project.json:
"commands": {
"web": "Microsoft.AspNet.Server.Kestrel --config hosting.json"
},
In a command prompt simply run dnx web, output:
Hosting environment: Production
Now listening on: http://localhost:5000
Now listening on: http://192.168.1.4:5000
Application started. Press Ctrl+C to shut down.
You'll get a firwall prompt, accept it, and tadaaa!! You can access the site from the LAN and localhost.

Categories