Skip to content
This repository was archived by the owner on Dec 4, 2023. It is now read-only.

Commit db0ba0c

Browse files
[#1364] Move Java generators from Samples to "generators" - Empty bot (#1391)
* Add generators empty bot * Apply update from samples PR#3627 Co-authored-by: tracyboehrer <tracyboehrer@users.noreply.github.com>
1 parent 380b3b4 commit db0ba0c

File tree

12 files changed

+1476
-0
lines changed

12 files changed

+1476
-0
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# <%= botName %>
2+
3+
This bot has been created using [Bot Framework](https://dev.botframework.com), it shows how to create a simple bot that accepts input from the user and echoes it back.
4+
5+
This sample is a Spring Boot app and uses the Azure CLI and azure-webapp Maven plugin to deploy to Azure.
6+
7+
## Prerequisites
8+
9+
- Java 1.8+
10+
- Install [Maven](https://maven.apache.org/)
11+
- An account on [Azure](https://azure.microsoft.com) if you want to deploy to Azure.
12+
13+
## To try this sample locally
14+
- From the root of this project folder:
15+
- Build the sample using `mvn package`
16+
- Run it by using `java -jar .\target\<%= artifact %>-1.0.0.jar`
17+
18+
- Test the bot using Bot Framework Emulator
19+
20+
[Bot Framework Emulator](https://github.com/microsoft/botframework-emulator) is a desktop application that allows bot developers to test and debug their bots on localhost or running remotely through a tunnel.
21+
22+
- Install the Bot Framework Emulator version 4.3.0 or greater from [here](https://github.com/Microsoft/BotFramework-Emulator/releases)
23+
24+
- Connect to the bot using Bot Framework Emulator
25+
26+
- Launch Bot Framework Emulator
27+
- File -> Open Bot
28+
- Enter a Bot URL of `http://localhost:3978/api/messages`
29+
30+
## Deploy the bot to Azure
31+
32+
As described on [Deploy your bot](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-deploy-az-cli), you will perform the first 4 steps to setup the Azure app, then deploy the code using the azure-webapp Maven plugin.
33+
34+
### 1. Login to Azure
35+
From a command (or PowerShell) prompt in the root of the bot folder, execute:
36+
`az login`
37+
38+
### 2. Set the subscription
39+
`az account set --subscription "<azure-subscription>"`
40+
41+
If you aren't sure which subscription to use for deploying the bot, you can view the list of subscriptions for your account by using `az account list` command.
42+
43+
### 3. Create an App registration
44+
`az ad app create --display-name "<botname>" --password "<appsecret>" --available-to-other-tenants`
45+
46+
Replace `<botname>` and `<appsecret>` with your own values.
47+
48+
`<botname>` is the unique name of your bot.
49+
`<appsecret>` is a minimum 16 character password for your bot.
50+
51+
Record the `appid` from the returned JSON
52+
53+
### 4. Create the Azure resources
54+
Replace the values for `<appid>`, `<appsecret>`, `<botname>`, and `<groupname>` in the following commands:
55+
56+
#### To a new Resource Group
57+
`az deployment sub create --name "echoBotDeploy" --location "westus" --template-file ".\deploymentTemplates\template-with-new-rg.json" --parameters appId="<appid>" appSecret="<appsecret>" botId="<botname>" botSku=S1 newAppServicePlanName="echoBotPlan" newWebAppName="echoBot" groupLocation="westus" newAppServicePlanLocation="westus"`
58+
59+
#### To an existing Resource Group
60+
`az deployment group create --resource-group "<groupname>" --template-file ".\deploymentTemplates\template-with-preexisting-rg.json" --parameters appId="<appid>" appSecret="<appsecret>" botId="<botname>" newWebAppName="echoBot" newAppServicePlanName="echoBotPlan" appServicePlanLocation="westus" --name "echoBot"`
61+
62+
### 5. Update app id and password
63+
In src/main/resources/application.properties update
64+
- `MicrosoftAppPassword` with the botsecret value
65+
- `MicrosoftAppId` with the appid from the first step
66+
67+
### 6. Deploy the code
68+
- Execute `mvn clean package`
69+
- Execute `mvn azure-webapp:deploy -Dgroupname="<groupname>" -Dbotname="<botname>"`
70+
71+
If the deployment is successful, you will be able to test it via "Test in Web Chat" from the Azure Portal using the "Bot Channel Registration" for the bot.
72+
73+
After the bot is deployed, you only need to execute #6 if you make changes to the bot.
74+
75+
76+
## Further reading
77+
78+
- [Maven Plugin for Azure App Service](https://docs.microsoft.com/en-us/java/api/overview/azure/maven/azure-webapp-maven-plugin/readme?view=azure-java-stable)
79+
- [Spring Boot](https://spring.io/projects/spring-boot)
80+
- [Azure for Java cloud developers](https://docs.microsoft.com/en-us/azure/java/?view=azure-java-stable)
81+
- [Bot Framework Documentation](https://docs.botframework.com)
82+
- [Bot Basics](https://docs.microsoft.com/azure/bot-service/bot-builder-basics?view=azure-bot-service-4.0)
83+
- [Activity processing](https://docs.microsoft.com/en-us/azure/bot-service/bot-builder-concept-activity-processing?view=azure-bot-service-4.0)
84+
- [Azure Bot Service Introduction](https://docs.microsoft.com/azure/bot-service/bot-service-overview-introduction?view=azure-bot-service-4.0)
85+
- [Azure Bot Service Documentation](https://docs.microsoft.com/azure/bot-service/?view=azure-bot-service-4.0)
Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"groupLocation": {
6+
"defaultValue": "",
7+
"type": "string",
8+
"metadata": {
9+
"description": "Specifies the location of the Resource Group."
10+
}
11+
},
12+
"groupName": {
13+
"type": "string",
14+
"metadata": {
15+
"description": "Specifies the name of the Resource Group."
16+
}
17+
},
18+
"appId": {
19+
"type": "string",
20+
"metadata": {
21+
"description": "Active Directory App ID, set as MicrosoftAppId in the Web App's Application Settings."
22+
}
23+
},
24+
"appSecret": {
25+
"type": "string",
26+
"metadata": {
27+
"description": "Active Directory App Password, set as MicrosoftAppPassword in the Web App's Application Settings."
28+
}
29+
},
30+
"botId": {
31+
"type": "string",
32+
"metadata": {
33+
"description": "The globally unique and immutable bot ID. Also used to configure the displayName of the bot, which is mutable."
34+
}
35+
},
36+
"botSku": {
37+
"defaultValue": "S1",
38+
"type": "string",
39+
"metadata": {
40+
"description": "The pricing tier of the Bot Service Registration. Acceptable values are F0 and S1."
41+
}
42+
},
43+
"newAppServicePlanName": {
44+
"defaultValue": "",
45+
"type": "string",
46+
"metadata": {
47+
"description": "The name of the App Service Plan."
48+
}
49+
},
50+
"newAppServicePlanSku": {
51+
"type": "object",
52+
"defaultValue": {
53+
"name": "P1v2",
54+
"tier": "PremiumV2",
55+
"size": "P1v2",
56+
"family": "Pv2",
57+
"capacity": 1
58+
},
59+
"metadata": {
60+
"description": "The SKU of the App Service Plan. Defaults to Standard values."
61+
}
62+
},
63+
"newAppServicePlanLocation": {
64+
"defaultValue": "",
65+
"type": "string",
66+
"metadata": {
67+
"description": "The location of the App Service Plan. Defaults to \"westus\"."
68+
}
69+
},
70+
"newWebAppName": {
71+
"type": "string",
72+
"defaultValue": "",
73+
"metadata": {
74+
"description": "The globally unique name of the Web App. Defaults to the value passed in for \"botId\"."
75+
}
76+
}
77+
},
78+
"variables": {
79+
"appServicePlanName": "[parameters('newAppServicePlanName')]",
80+
"resourcesLocation": "[parameters('newAppServicePlanLocation')]",
81+
"webAppName": "[if(empty(parameters('newWebAppName')), parameters('botId'), parameters('newWebAppName'))]",
82+
"siteHost": "[concat(variables('webAppName'), '.azurewebsites.net')]",
83+
"botEndpoint": "[concat('https://', variables('siteHost'), '/api/messages')]",
84+
"publishingUsername": "[concat('$', parameters('newWebAppName'))]",
85+
"resourceGroupId": "[concat(subscription().id, '/resourceGroups/', parameters('groupName'))]"
86+
},
87+
"resources": [
88+
{
89+
"name": "[parameters('groupName')]",
90+
"type": "Microsoft.Resources/resourceGroups",
91+
"apiVersion": "2018-05-01",
92+
"location": "[parameters('groupLocation')]",
93+
"properties": {}
94+
},
95+
{
96+
"type": "Microsoft.Resources/deployments",
97+
"apiVersion": "2018-05-01",
98+
"name": "storageDeployment",
99+
"resourceGroup": "[parameters('groupName')]",
100+
"dependsOn": [
101+
"[resourceId('Microsoft.Resources/resourceGroups/', parameters('groupName'))]"
102+
],
103+
"properties": {
104+
"mode": "Incremental",
105+
"template": {
106+
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
107+
"contentVersion": "1.0.0.0",
108+
"parameters": {},
109+
"variables": {},
110+
"resources": [
111+
{
112+
"comments": "Create a new Linux App Service Plan if no existing App Service Plan name was passed in.",
113+
"type": "Microsoft.Web/serverfarms",
114+
"name": "[variables('appServicePlanName')]",
115+
"apiVersion": "2018-02-01",
116+
"location": "[variables('resourcesLocation')]",
117+
"sku": "[parameters('newAppServicePlanSku')]",
118+
"kind": "linux",
119+
"properties": {
120+
"perSiteScaling": false,
121+
"maximumElasticWorkerCount": 1,
122+
"isSpot": false,
123+
"reserved": true,
124+
"isXenon": false,
125+
"hyperV": false,
126+
"targetWorkerCount": 0,
127+
"targetWorkerSizeId": 0
128+
}
129+
},
130+
{
131+
"comments": "Create a Web App using a Linux App Service Plan",
132+
"type": "Microsoft.Web/sites",
133+
"apiVersion": "2018-11-01",
134+
"location": "[variables('resourcesLocation')]",
135+
"kind": "app,linux",
136+
"dependsOn": [
137+
"[concat(variables('resourceGroupId'), '/providers/Microsoft.Web/serverfarms/', variables('appServicePlanName'))]"
138+
],
139+
"name": "[variables('webAppName')]",
140+
"properties": {
141+
"name": "[variables('webAppName')]",
142+
"hostNameSslStates": [
143+
{
144+
"name": "[concat(parameters('newWebAppName'), '.azurewebsites.net')]",
145+
"sslState": "Disabled",
146+
"hostType": "Standard"
147+
},
148+
{
149+
"name": "[concat(parameters('newWebAppName'), '.scm.azurewebsites.net')]",
150+
"sslState": "Disabled",
151+
"hostType": "Repository"
152+
}
153+
],
154+
"serverFarmId": "[variables('appServicePlanName')]",
155+
"reserved": true,
156+
"isXenon": false,
157+
"hyperV": false,
158+
"scmSiteAlsoStopped": false,
159+
"clientAffinityEnabled": true,
160+
"clientCertEnabled": false,
161+
"hostNamesDisabled": false,
162+
"containerSize": 0,
163+
"dailyMemoryTimeQuota": 0,
164+
"httpsOnly": false,
165+
"redundancyMode": "None",
166+
"siteConfig": {
167+
"appSettings": [
168+
{
169+
"name": "JAVA_OPTS",
170+
"value": "-Dserver.port=80"
171+
},
172+
{
173+
"name": "MicrosoftAppId",
174+
"value": "[parameters('appId')]"
175+
},
176+
{
177+
"name": "MicrosoftAppPassword",
178+
"value": "[parameters('appSecret')]"
179+
}
180+
],
181+
"cors": {
182+
"allowedOrigins": [
183+
"https://botservice.hosting.portal.azure.net",
184+
"https://hosting.onecloud.azure-test.net/"
185+
]
186+
}
187+
}
188+
}
189+
},
190+
{
191+
"type": "Microsoft.Web/sites/config",
192+
"apiVersion": "2018-11-01",
193+
"name": "[concat(variables('webAppName'), '/web')]",
194+
"location": "[variables('resourcesLocation')]",
195+
"dependsOn": [
196+
"[concat(variables('resourceGroupId'), '/providers/Microsoft.Web/sites/', variables('webAppName'))]"
197+
],
198+
"properties": {
199+
"numberOfWorkers": 1,
200+
"defaultDocuments": [
201+
"Default.htm",
202+
"Default.html",
203+
"Default.asp",
204+
"index.htm",
205+
"index.html",
206+
"iisstart.htm",
207+
"default.aspx",
208+
"index.php",
209+
"hostingstart.html"
210+
],
211+
"netFrameworkVersion": "v4.0",
212+
"linuxFxVersion": "JAVA|8-jre8",
213+
"requestTracingEnabled": false,
214+
"remoteDebuggingEnabled": false,
215+
"httpLoggingEnabled": false,
216+
"logsDirectorySizeLimit": 35,
217+
"detailedErrorLoggingEnabled": false,
218+
"publishingUsername": "[variables('publishingUsername')]",
219+
"scmType": "None",
220+
"use32BitWorkerProcess": true,
221+
"webSocketsEnabled": false,
222+
"alwaysOn": true,
223+
"managedPipelineMode": "Integrated",
224+
"virtualApplications": [
225+
{
226+
"virtualPath": "/",
227+
"physicalPath": "site\\wwwroot",
228+
"preloadEnabled": true
229+
}
230+
],
231+
"loadBalancing": "LeastRequests",
232+
"experiments": {
233+
"rampUpRules": []
234+
},
235+
"autoHealEnabled": false,
236+
"localMySqlEnabled": false,
237+
"ipSecurityRestrictions": [
238+
{
239+
"ipAddress": "Any",
240+
"action": "Allow",
241+
"priority": 1,
242+
"name": "Allow all",
243+
"description": "Allow all access"
244+
}
245+
],
246+
"scmIpSecurityRestrictions": [
247+
{
248+
"ipAddress": "Any",
249+
"action": "Allow",
250+
"priority": 1,
251+
"name": "Allow all",
252+
"description": "Allow all access"
253+
}
254+
],
255+
"scmIpSecurityRestrictionsUseMain": false,
256+
"http20Enabled": false,
257+
"minTlsVersion": "1.2",
258+
"ftpsState": "AllAllowed",
259+
"reservedInstanceCount": 0
260+
}
261+
},
262+
{
263+
"apiVersion": "2021-03-01",
264+
"type": "Microsoft.BotService/botServices",
265+
"name": "[parameters('botId')]",
266+
"location": "global",
267+
"kind": "azurebot",
268+
"sku": {
269+
"name": "[parameters('botSku')]"
270+
},
271+
"properties": {
272+
"name": "[parameters('botId')]",
273+
"displayName": "[parameters('botId')]",
274+
"iconUrl": "https://docs.botframework.com/static/devportal/client/images/bot-framework-default.png",
275+
"endpoint": "[variables('botEndpoint')]",
276+
"msaAppId": "[parameters('appId')]",
277+
"luisAppIds": [],
278+
"schemaTransformationVersion": "1.3",
279+
"isCmekEnabled": false,
280+
"isIsolated": false
281+
},
282+
"dependsOn": [
283+
"[concat(variables('resourceGroupId'), '/providers/Microsoft.Web/sites/', variables('webAppName'))]"
284+
]
285+
}
286+
],
287+
"outputs": {}
288+
}
289+
}
290+
}
291+
]
292+
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy