Skip to content

Commit

Permalink
EchoBot Deployment Fixes and Nuget package updates (#733)
Browse files Browse the repository at this point in the history
* updated workflow module versions

* added sas token into bicep of VMSS for DSC

* added ds_store to gitignore

* added BCN environment

* updated log category for LB

* updated nuget packages

* updated nuget package, fixed breaking changes and removed unused code

* removed environment files

* updated readme note to callout the azure bot creation step.

---------

Co-authored-by: Brennen Cage <[email protected]>
  • Loading branch information
bcage29 and Brennen Cage authored Jul 15, 2024
1 parent 35b5f82 commit d01928c
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 75 deletions.
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,9 @@ _site/
appsettings.development.json
*.development.pubxml
*.original

# MAC temp file
.DS_Store

# Cache file that gets created when running audio bot
*.dat
6 changes: 1 addition & 5 deletions Samples/PublicSamples/EchoBot/ADF/bicep/LB-LB.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,7 @@ resource LBalancerDiag 'Microsoft.Insights/diagnosticSettings@2021-05-01-preview
workspaceId: OMSworkspaceID
logs: [
{
category: 'LoadBalancerAlertEvent'
enabled: true
}
{
category: 'LoadBalancerProbeHealthStatus'
category: 'LoadBalancerHealthEvent'
enabled: true
}
]
Expand Down
21 changes: 19 additions & 2 deletions Samples/PublicSamples/EchoBot/ADF/bicep/VMSS-VM.bicep
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ param devOpsPat string
@secure()
param sshPublic string

param month string = utcNow('MM')
param year string = utcNow('yyyy')

var Deployment = '${Prefix}-${Global.OrgName}-${Global.Appname}-${Environment}${DeploymentID}'
var DeploymentURI = toLower('${Prefix}${Global.OrgName}${Global.Appname}${Environment}${DeploymentID}')

Expand Down Expand Up @@ -54,6 +57,20 @@ resource saaccountidglobalsource 'Microsoft.Storage/storageAccounts@2021-04-01'
name: Global.SAName
}

// Use same PAT token for 3 month blocks, min PAT age is 6 months, max is 9 months
var SASEnd = dateTimeAdd('${year}-${padLeft((int(month) - (int(month) -1) % 3),2,'0')}-01', 'P9M')

// Roll the SAS token one per 3 months, min length of 6 months.
var DSCSAS = saaccountidglobalsource.listServiceSAS('2021-09-01', {
canonicalizedResource: '/blob/${saaccountidglobalsource.name}/${last(split(Global._artifactsLocation, '/'))}'
signedResource: 'c'
signedProtocol: 'https'
signedPermission: 'r'
signedServices: 'b'
signedExpiry: SASEnd
keyToSign: 'key1'
}).serviceSasToken

var DSCConfigLookup = {
AppServers: 'AppServers'
InitialDOP: 'AppServers'
Expand Down Expand Up @@ -390,8 +407,8 @@ resource VMSS 'Microsoft.Compute/virtualMachineScaleSets@2021-07-01' = {
Password: vmAdminPassword
}
}
configurationUrlSasToken: Global._artifactsLocationSasToken
configurationDataUrlSasToken: Global._artifactsLocationSasToken
configurationUrlSasToken: '?${DSCSAS}'
configurationDataUrlSasToken: '?${DSCSAS}'
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,7 @@ Function global:AzDeploy
throw 'Please run the deploy.ps1 or Create-StorageAccount.ps1'
}

$SASParams = @{
Container = $StorageContainerName
Context = $StorageAccount.Context
Permission = 'r'
ExpiryTime = (Get-Date).AddHours(40)
}
$queryString = (New-AzStorageContainerSASToken @SASParams).Substring(1)
$Global['_artifactsLocation'] = $TemplateURIBase
$Global['_artifactsLocationSasToken'] = "?${queryString}"
$Global['OrgName'] = $OrgName
$Global['AppName'] = $App
$Global['SAName'] = $StorageAccountName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,6 @@ jobs:
steps:
- uses: actions/checkout@v2

# Add wait on concurrent workflows executing via https://github.com/marketplace/actions/action-turnstyle
- name: Turnstyle
uses: softprops/turnstyle@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1

Expand Down Expand Up @@ -67,13 +61,13 @@ jobs:
echo ${{ github.workspace }}
- name: Login via Az module
uses: azure/login@v1
uses: azure/login@v2
with:
creds: ${{ secrets.AZURE_CREDENTIALS_{OrgName}_BOT }}
enable-AzPSSession: true

- name: G1_RG_UploadArtifacts_to_Blob
uses: Azure/powershell@v1
uses: Azure/powershell@v2
with:
inlineScript: |
Get-ChildItem -Path ./${{ env.Base }}/${{ env.Component }}/${{ env.BuildName }}/ # -Recurse
Expand All @@ -90,7 +84,7 @@ jobs:
azPSVersion: latest

- name: G1_RG_UpdateBuildMeta_to_Blob
uses: Azure/powershell@v1
uses: Azure/powershell@v2
with:
inlineScript: |
echo $home
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,14 @@ jobs:
- name: Checkout
uses: actions/checkout@v2

# Add wait on concurrent workflows executing via https://github.com/marketplace/actions/action-turnstyle
- name: Turnstyle
uses: softprops/turnstyle@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Login via Az module
uses: azure/login@v1
uses: azure/login@v2
with:
creds: ${{secrets.AZURE_CREDENTIALS_{OrgName}_BOT}}
enable-AzPSSession: true

- name: Deploy_All_Subscription
uses: Azure/powershell@v1
uses: Azure/powershell@v2
with:
azPSVersion: latest
inlineScript: |
Expand All @@ -58,5 +52,3 @@ jobs:
}
./Samples/PublicSamples/EchoBot/ADF/main.ps1 @Params
if ($e){throw $e}
env:
VMSS_CREDENTIALS: ${{ secrets.VMSS_CREDENTIALS_{OrgName}_BOT }}
2 changes: 1 addition & 1 deletion Samples/PublicSamples/EchoBot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ openssl pkcs12 -export -out C:\Certbot\live\example.com\star_example_com.pfx -in

## Bot Registration

1. Follow the instructions [Register a Calling Bot](https://microsoftgraph.github.io/microsoft-graph-comms-samples/docs/articles/calls/register-calling-bot.html). Take a note of the registered config values (Bot Id, MicrosoftAppId and MicrosoftAppPassword). You will need these values in the code sample config.
1. Follow the instructions [Register a Calling Bot](https://microsoftgraph.github.io/microsoft-graph-comms-samples/docs/articles/calls/register-calling-bot.html). Take a note of the registered config values (Bot Id, MicrosoftAppId and MicrosoftAppPassword). You will need these values in the code sample config. NOTE: This step is creating an Azure Bot. If the bot is not created and configured correctly, the bot will not be able to join the meeting.

1. Add the following Application Permissions to the bot:

Expand Down
2 changes: 2 additions & 0 deletions Samples/PublicSamples/EchoBot/src/EchoBot/Bot/BotService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
using System.Collections.Concurrent;
using System.Net;
using EchoBot.Util;
using Microsoft.Graph.Models;
using Microsoft.Graph.Contracts;

namespace EchoBot.Bot
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Microsoft.Graph.Communications.Calls.Media;
using Microsoft.Graph.Communications.Common.Telemetry;
using Microsoft.Graph.Communications.Resources;
using Microsoft.Graph.Models;
using System.Timers;

namespace EchoBot.Bot
Expand Down
14 changes: 7 additions & 7 deletions Samples/PublicSamples/EchoBot/src/EchoBot/EchoBot.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="DotNetEnv" Version="2.5.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.21.0" />
<PackageReference Include="Microsoft.CognitiveServices.Speech" Version="1.32.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="6.0.2" />
<PackageReference Include="Microsoft.Graph.Communications.Calls.Media" Version="1.2.0.7270" />
<PackageReference Include="DotNetEnv" Version="3.0.0" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0" />
<PackageReference Include="Microsoft.CognitiveServices.Speech" Version="1.38.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Microsoft.Extensions.Hosting.WindowsServices" Version="8.0.0" />
<PackageReference Include="Microsoft.Graph.Communications.Calls.Media" Version="1.2.0.10563" />
<PackageReference Include="Microsoft.Skype.Bots.Media" Version="1.27.0.2-alpha" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.6.2" />
</ItemGroup>
</Project>
2 changes: 2 additions & 0 deletions Samples/PublicSamples/EchoBot/src/EchoBot/Models/JoinInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
// <summary></summary>
// ***********************************************************************
using Microsoft.Graph;
using Microsoft.Graph.Contracts;
using Microsoft.Graph.Models;
using System.Net;
using System.Runtime.Serialization.Json;
using System.Text;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,38 +48,5 @@ public static async Task ForgetAndLogExceptionAsync(
lineNumber: lineNumber);
}
}
/// <summary>
/// Inspect the exception type/error and return the correct response.
/// </summary>
/// <param name="exception">The caught exception.</param>
/// <returns>The <see cref="HttpResponseMessage" />.</returns>
public static HttpResponseMessage InspectExceptionAndReturnResponse(this Exception exception)
{
HttpResponseMessage responseToReturn;
if (exception is ServiceException e)
{
responseToReturn = (int)e.StatusCode >= 200
? new HttpResponseMessage(e.StatusCode)
: new HttpResponseMessage(HttpStatusCode.InternalServerError);
if (e.ResponseHeaders != null)
{
foreach (var responseHeader in e.ResponseHeaders)
{
responseToReturn.Headers.TryAddWithoutValidation(responseHeader.Key, responseHeader.Value);
}
}

responseToReturn.Content = new StringContent(e.ToString());
}
else
{
responseToReturn = new HttpResponseMessage(HttpStatusCode.InternalServerError)
{
Content = new StringContent(exception.ToString()),
};
}

return responseToReturn;
}
}
}

0 comments on commit d01928c

Please sign in to comment.