Skip to content

Commit

Permalink
Fixes to hue bot. (microsoftgraph#100)
Browse files Browse the repository at this point in the history
  • Loading branch information
ksikorsk authored Jul 17, 2019
1 parent a26fed4 commit e775543
Show file tree
Hide file tree
Showing 12 changed files with 55 additions and 33 deletions.
2 changes: 1 addition & 1 deletion Samples/CommsSamples.sln
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{E5ADF206-0845-436D-8A70-826DE8082A8C}"
ProjectSection(SolutionItems) = preProject
..\changelog.md = ..\changelog.md
configure_cloud.ps1 = configure_cloud.ps1
..\LICENSE = ..\LICENSE
..\README.md = ..\README.md
EndProjectSection
Expand All @@ -57,7 +58,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "V1.0Samples", "V1.0Samples"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "LocalMediaSamples", "LocalMediaSamples", "{A6303F54-64FF-4FFC-921C-3F383D26F807}"
ProjectSection(SolutionItems) = preProject
V1.0Samples\LocalMediaSamples\configure_cloud.ps1 = V1.0Samples\LocalMediaSamples\configure_cloud.ps1
V1.0Samples\LocalMediaSamples\E-SDK Samples.postman_collection.json = V1.0Samples\LocalMediaSamples\E-SDK Samples.postman_collection.json
V1.0Samples\LocalMediaSamples\README.md = V1.0Samples\LocalMediaSamples\README.md
EndProjectSection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

<appSettings>
<!-- update these with your Bot Id, AAD application id and your AAD application secret from your bot registration portal. -->
<add key="BotId" value="%BotId%" />
<add key="BotName" value="%BotName%" />
<add key="AadAppId" value="%AppId%" />
<add key="AadAppSecret" value="%AppSecret%" />
<add key="H264_1280x720_30Fps" value="output720p.264" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"value": "westus"
},
"clusterName": {
"value": "huebotsf02"
"value": "%BotNameLower%"
},
"adminUserName": {
"value": "huebot"
Expand Down Expand Up @@ -63,4 +63,4 @@
"value": "Standard_D2_V2"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -445,8 +445,8 @@
"frontendIPConfiguration": {
"id": "[variables('lbIPConfig0')]"
},
"frontendPortRangeEnd": "8100",
"frontendPortRangeStart": "8000",
"frontendPortRangeEnd": "8545",
"frontendPortRangeStart": "8445",
"protocol": "tcp"
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,7 @@ private MediaPlatformSettings MediaInit(BotOptions options, StatefulServiceConte
{
CertificateThumbprint = options.Certificate,
InstanceInternalPort = serviceContext.CodePackageActivationContext.GetEndpoint("MediaPort").Port,
InstancePublicIPAddress = new IPAddress(0x0), //// instanceAddresses[0],
InstancePublicIPAddress = instanceAddresses[0],
InstancePublicPort = publicMediaUrl.Port + instanceNumber,
ServiceFqdn = publicMediaUrl.Host,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<SetupEntryPoint>
<ExeHost>
<Program>Startup.cmd</Program>
<Arguments></Arguments>
<Arguments>8445 ABC0000000000000000000000000000000000CBA</Arguments>
<WorkingFolder>CodePackage</WorkingFolder>
</ExeHost>
</SetupEntryPoint>
Expand Down Expand Up @@ -51,4 +51,4 @@
</Endpoints>
</Resources>

</ServiceManifest>
</ServiceManifest>
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"Bot": {
"AppId": "%AppId%",
"AppSecret": "%AppSecret%",
"BotBaseUrl": "https://huebotsxxxxx.xxxx.cloudapp.azure.com:9444/api/calls",
"BotMediaProcessorUrl": "net.tcp://huebotsxxxxx.xxxx.cloudapp.azure.com:8445",
"BotBaseUrl": "https://%CName%:9444/api/calls",
"BotMediaProcessorUrl": "net.tcp://%ServiceDns%:8445",
"Certificate": "ABC0000000000000000000000000000000000CBA",
"PlaceCallEndpointUrl": "https://graph.microsoft.com/beta"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,4 @@
<!-- The declaration "EndpointCertificate" implies that it'll be bound to an endpoint -->
<EndpointCertificate X509StoreName="MY" X509FindValue="ABC0000000000000000000000000000000000CBA" Name="HueBotCert" />
</Certificates>
</ApplicationManifest>
</ApplicationManifest>
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Application xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" Name="fabric:/HueBotSF" xmlns="http://schemas.microsoft.com/2011/01/fabric">
<Parameters>
<Parameter Name="HueBot_PartitionCount" Value="5" />
<Parameter Name="HueBot_MinReplicaSetSize" Value="1" />
<Parameter Name="HueBot_TargetReplicaSetSize" Value="1" />
</Parameters>
</Application>
</Application>
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
AzureActiveDirectory="true"
ServerCertThumbprint="0123456789012345678901234567890123456789" />
-->
<ClusterConnectionParameters ConnectionEndpoint="huebotsf02.westus.cloudapp.azure.com:19000" X509Credential="true" ServerCertThumbprint="ABC0000000000000000000000000000000000CBA" FindType="FindByThumbprint" FindValue="ABC0000000000000000000000000000000000CBA" StoreLocation="LocalMachine" StoreName="My" />
<ClusterConnectionParameters ConnectionEndpoint="%ServiceDns%:19000" X509Credential="true" ServerCertThumbprint="ABC0000000000000000000000000000000000CBA" FindType="FindByThumbprint" FindValue="ABC0000000000000000000000000000000000CBA" StoreLocation="LocalMachine" StoreName="My" />
<ApplicationParameterFile Path="..\ApplicationParameters\Cloud.xml" />
<CopyPackageParameters CompressPackage="true" />
<UpgradeDeployment Mode="Monitored" Enabled="false">
<Parameters FailureAction="Rollback" Force="True" />
</UpgradeDeployment>
</PublishProfile>
</PublishProfile>
51 changes: 36 additions & 15 deletions Samples/V1.0Samples/LocalMediaSamples/HueBot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,13 @@ For running locally, we need to use a tunneling mechanism to route traffic to yo
* Create a wildcard certificate. For instance, if your bot is hosted at `bot.contoso.com`, create the certificate for `*.contoso.com`.

1. [Azure] Upload the certificate to your key-vault instance.

![ConfigureCert1](Images/ConfigureCert1.png)

![ConfigureCert1](Images/ConfigureCert2.png)

1. [Azure] Copy the Secret Identifier to be used later.

![ConfigureCert1](Images/ConfigureCert3.png)

1. Install the certificate to the LocalMachine/My certificate folder on your dev machine, including the private keys. Save the thumbprint for later.
Expand All @@ -62,6 +65,7 @@ For running locally, we need to use a tunneling mechanism to route traffic to yo
```
1. Start ngrok: `ngrok.exe start -all -config %replace_with_path_to_your_ngrok.yml%`. You will see an output like this:

![ngrokScreenshot](Images/ngrokScreenshot.png)

1. From **your** output, note the 3 values in the places marked in red above. From now on, we will call them by these names:
Expand All @@ -73,11 +77,29 @@ For running locally, we need to use a tunneling mechanism to route traffic to yo

### Code

* Run the `configure_cloud.ps1` script to configure your application.
* Open a powershell session and navigate to the `/Samples` folder.
* Run the following command

```Powershell
.\configure_cloud.ps1 -p .\V1.0Samples\LocalMediaSamples\HueBot `
-dns {full cluster name: huebotxxxxx.xxxx.cloudapp.azure.com} `
-cn {full cluster name: huebotxxxxx.xxxx.cloudapp.azure.com} `
-thumb ABC0000000000000000000000000000000000CBA `
-bid {bot/cluster name: HueBotxxxxx} `
-aid {application id created during registration} `
-as {application secret created during registration}
```

Alternatively, you can configure your solution manually.

* Open the `HueBot.sln` in Visual Studio 2017 and search/replace these values:
* `%AppId%` and `%AppSecret%` that you obtained during application registration.
* Replace all `huebotsxxxxx.xxxx.cloudapp.azure.com` with your full cluster name.
* `%BotNameLower%` with your desired service fabric cluser name.
* Replace all `%ServiceDns%` with your full cluster name (I.E. huebotxxxxx.xxxx.cloudapp.azure.com).
* Replace all `%CName%` with your full cluster name (I.E. huebotxxxxx.xxxx.cloudapp.azure.com).
* Replace all certificate thumbprint `ABC0000000000000000000000000000000000CBA` with your certificate.
* in HueBot/PackageRoot/ServiceManifest.xml file, for Startup.cmd, add `8445 your certificate thumbprint` for \<Arguments\>. For example \<Arguments\>`8445 ABC0000000000000000000000000000000000CBA`\</Arguments\>

### Deploy

#### [Azure] deployment
Expand Down Expand Up @@ -129,12 +151,11 @@ Click `Start` on the top toolbar to deploy the sample to the local cluster.

##### Request
```json
POST https://huebotsxxxxx.xxxx.cloudapp.azure.com:9441/joinCall
POST https://huebotxxxxx.xxxx.cloudapp.azure.com:9441/joinCall
Content-Type: application/json
{
"JoinURL": "https://teams.microsoft.com/l/meetup-join/...",
"TenantId": "72f988bf-..."
"JoinURL": "https://teams.microsoft.com/l/meetup-join/..."
}
```

Expand All @@ -145,32 +166,32 @@ Click `Start` on the top toolbar to deploy the sample to the local cluster.
Content-Type: application/json
{
"callURL": "https://huebotsxxxxx.xxxx.cloudapp.azure.com:9445/calls/321a0b00-84de-415b-a31b-bdd1b0abe663/",
"callSnapshotURL": "https://huebotsxxxxx.xxxx.cloudapp.azure.com:9445/calls/321a0b00-84de-415b-a31b-bdd1b0abe663/scr",
"callHueURL": "https://huebotsxxxxx.xxxx.cloudapp.azure.com:9445/calls/321a0b00-84de-415b-a31b-bdd1b0abe663/hue",
"callsURL": "https://huebotsxxxxx.xxxx.cloudapp.azure.com:9445/calls/",
"serviceLogsURL": "https://huebotsxxxxx.xxxx.cloudapp.azure.com:9445/logs/"
"callURL": "https://huebotxxxxx.xxxx.cloudapp.azure.com:9445/calls/321a0b00-84de-415b-a31b-bdd1b0abe663/",
"callSnapshotURL": "https://huebotxxxxx.xxxx.cloudapp.azure.com:9445/calls/321a0b00-84de-415b-a31b-bdd1b0abe663/scr",
"callHueURL": "https://huebotxxxxx.xxxx.cloudapp.azure.com:9445/calls/321a0b00-84de-415b-a31b-bdd1b0abe663/hue",
"callsURL": "https://huebotxxxxx.xxxx.cloudapp.azure.com:9445/calls/",
"serviceLogsURL": "https://huebotxxxxx.xxxx.cloudapp.azure.com:9445/logs/"
}
```

1. Change hue for the bot through a `PUT`. Replace the call id 321a0b00-84de-415b-a31b-bdd1b0abe663 below with your call id from the first response.

##### Request
```json
PUT https://huebotsxxxxx.xxxx.cloudapp.azure.com:9445/calls/321a0b00-84de-415b-a31b-bdd1b0abe663/hue
PUT https://huebotxxxxx.xxxx.cloudapp.azure.com:9445/calls/321a0b00-84de-415b-a31b-bdd1b0abe663/hue
Content-Type: application/json
"green"
```

1. Get diagnostics data from the bot. Open the links in a browser for auto-refresh. Replace the call id 321a0b00-84de-415b-a31b-bdd1b0abe663 below with your call id from the first response.
Call logs: https://huebotsxxxxx.xxxx.cloudapp.azure.com:9445/logs/321a0b00-84de-415b-a31b-bdd1b0abe663/
Active calls: https://huebotsxxxxx.xxxx.cloudapp.azure.com:9445/calls
Service logs: https://huebotsxxxxx.xxxx.cloudapp.azure.com:9445/logs
Call logs: https://huebotxxxxx.xxxx.cloudapp.azure.com:9445/logs/321a0b00-84de-415b-a31b-bdd1b0abe663/
Active calls: https://huebotxxxxx.xxxx.cloudapp.azure.com:9445/calls
Service logs: https://huebotxxxxx.xxxx.cloudapp.azure.com:9445/logs

1. Terminating the call through `DELETE`. Replace the call id 321a0b00-84de-415b-a31b-bdd1b0abe663 below with your call id from the first response.

##### Request
```json
DELETE https://huebotsxxxxx.xxxx.cloudapp.azure.com:9445/calls/321a0b00-84de-415b-a31b-bdd1b0abe663
DELETE https://huebotxxxxx.xxxx.cloudapp.azure.com:9445/calls/321a0b00-84de-415b-a31b-bdd1b0abe663
```
5 changes: 3 additions & 2 deletions Samples/configure_cloud.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ param(

Write-Output 'Microsoft BotBuilder Enterprise SDK - Azure Cloud Configurator'

$Files = "ServiceConfiguration.Cloud.cscfg", "ServiceConfiguration.Local.cscfg", "app.config", "appsettings.json"
$Files = "ServiceConfiguration.Cloud.cscfg", "ServiceConfiguration.Local.cscfg", "app.config", "appsettings.json", "cloud.xml", "ServiceManifest.xml", "ApplicationManifest.xml", "AzureDeploy.Parameters.json"
[System.Collections.ArrayList]$FilesToReplace = @()

foreach($file in $Files)
Expand Down Expand Up @@ -143,7 +143,8 @@ foreach($file in $FilesToReplace)
ReplaceInFile $file "%ServiceDns%" $ServiceDns
ReplaceInFile $file "%CName%" $CName
ReplaceInFile $file "ABC0000000000000000000000000000000000CBA" $CertThumbprint
ReplaceInFile $file "%BotId%" $BotName
ReplaceInFile $file "%BotName%" $BotName
ReplaceInFile $file "%BotNameLower%" $BotName.ToLower()
ReplaceInFile $file "%AppId%" $AppId
ReplaceInFile $file "%AppSecret%" $AppSecret
}
Expand Down

0 comments on commit e775543

Please sign in to comment.