Skip to content

Commit

Permalink
Update tooling to latest Functions version (#190)
Browse files Browse the repository at this point in the history
* Update tooling for Hello samples

* update tooling in load generator and performance tests

* remove unneded dependency on Microsoft.Azure.Functions.Extensions

* harden unit test logger
  • Loading branch information
sebastianburckhardt authored Aug 16, 2022
1 parent dfac505 commit 38b75d7
Show file tree
Hide file tree
Showing 26 changed files with 121 additions and 74 deletions.
4 changes: 2 additions & 2 deletions DurableTask.Netherite.sln
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,15 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{D33AB157-04B
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "test", "test", "{4A7226CF-57BF-4CA3-A4AC-91A398A1D84B}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Hello", "samples\Hello_Netherite_with_DotNetCore\Hello.csproj", "{654DA6B4-2E2F-4386-BB9F-7CE5A13998DE}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloDF", "samples\Hello_Netherite_with_DotNetCore\HelloDF.csproj", "{654DA6B4-2E2F-4386-BB9F-7CE5A13998DE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "samples", "samples", "{AB958467-9236-402E-833C-B8DE4841AB9F}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ScaleMonitor", "test\ScaleMonitor\ScaleMonitor.csproj", "{2F4D331C-62E4-47E8-852E-163166944DF8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LoadGeneratorApp", "test\LoadGeneratorApp\LoadGeneratorApp.csproj", "{78B360B8-3A41-4DC0-A300-94A0FABC1FB0}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloDTFx", "samples\HelloDTFx\HelloDTFx\HelloDTFx.csproj", "{EC293D85-91E3-4F78-8B1E-2C691315CE96}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "HelloDTFx", "samples\HelloDTFx\HelloDTFx\HelloDTFx.csproj", "{EC293D85-91E3-4F78-8B1E-2C691315CE96}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
19 changes: 0 additions & 19 deletions samples/Hello_Netherite_with_DotNetCore/Hello.csproj

This file was deleted.

20 changes: 20 additions & 0 deletions samples/Hello_Netherite_with_DotNetCore/HelloDF.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.DurableTask.Netherite.AzureFunctions" Version="1.1.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.7.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ Write-Host Building $Configuration Configuration...
dotnet build -c $Configuration

# enter the directory with the binaries
Push-Location -Path bin/$Configuration/netcoreapp3.1

Push-Location -Path bin/$Configuration/net6.0

Write-Host "Publishing Code to Function App..."
func azure functionapp publish $functionAppName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
dotnet build

# enter the directory with the debug binaries
if (-not (Test-Path -Path ./bin/Debug/netcoreapp3.1/bin)) {
if (-not (Test-Path -Path ./bin/Debug/net6.0/bin)) {
throw 'No debug binaries found. Must `dotnet build` first.'
} else {
cd bin/Debug/netcoreapp3.1
cd bin/Debug/net6.0
}

# look up the two connection strings and assign them to the respective environment variables
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions samples/scripts/create-function-app.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ if (-not ((az functionapp list -g $groupName --query "[].name" | ConvertFrom-Jso

if ($Runtime -eq "dotnet") {
Write-Host "for .NET"
az functionapp create --name $functionAppName --storage-account $storageName --plan $functionAppName --resource-group $groupName --functions-version 3 --runtime $Runtime --os-type $OsType
az functionapp create --name $functionAppName --storage-account $storageName --plan $functionAppName --resource-group $groupName --functions-version 4 --runtime $Runtime --os-type $OsType
}
else {
Write-Host "for $Runtime"
az functionapp create --name $functionAppName --storage-account $storageName --plan $functionAppName --resource-group $groupName --functions-version 3 --runtime $Runtime --runtime-version $RuntimeVersion --os-type $OsType
az functionapp create --name $functionAppName --storage-account $storageName --plan $functionAppName --resource-group $groupName --functions-version 4 --runtime $Runtime --runtime-version $RuntimeVersion --os-type $OsType
}

az functionapp config set -n $functionAppName -g $groupName --use-32bit-worker-process false
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
. ./settings.ps1

Write-Host "Deleting Resource Group..."
az group delete --name $groupName
az group delete --name $groupName --yes
11 changes: 11 additions & 0 deletions samples/scripts/delete-function-app.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/pwsh

# read the generic parameters
. ./settings.ps1

Write-Host "Deleting Function App..."
az functionapp delete --resource-group $groupName --name $functionAppName

Write-Host "Deleting Function Plan..."
az functionapp plan delete --resource-group $groupName --name $functionAppName --yes

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
<ItemGroup>
<PackageReference Include="Microsoft.Azure.DurableTask.Core" Version="2.10.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.7.2" />
<PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.1.0" />
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' != 'netcoreapp2.2' ">
Expand Down
45 changes: 28 additions & 17 deletions test/DurableTask.Netherite.Tests/XunitLoggerProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,24 +41,35 @@ public void Log<TState>(LogLevel logLevel, Microsoft.Extensions.Logging.EventId
// Write the information to the system trace
string formattedString = formatter(state, exception);

switch (logLevel)
int attempts = 0;
while (++attempts <= 2)
{
case LogLevel.Information:
case LogLevel.Debug:
case LogLevel.Trace:
System.Diagnostics.Trace.TraceInformation(formattedString);
break;
case LogLevel.Error:
case LogLevel.Critical:
System.Diagnostics.Trace.TraceError(formattedString);
if (exception != null)
System.Diagnostics.Trace.TraceError(exception.ToString());
break;
case LogLevel.Warning:
System.Diagnostics.Trace.TraceWarning(formattedString);
if (exception != null)
System.Diagnostics.Trace.TraceWarning(exception.ToString());
break;
try
{
switch (logLevel)
{
case LogLevel.Information:
case LogLevel.Debug:
case LogLevel.Trace:
System.Diagnostics.Trace.TraceInformation(formattedString);
break;
case LogLevel.Error:
case LogLevel.Critical:
System.Diagnostics.Trace.TraceError(formattedString);
if (exception != null)
System.Diagnostics.Trace.TraceError(exception.ToString());
break;
case LogLevel.Warning:
System.Diagnostics.Trace.TraceWarning(formattedString);
if (exception != null)
System.Diagnostics.Trace.TraceWarning(exception.ToString());
break;
}
}
catch (InvalidOperationException) when (attempts < 2)
{
continue; // logger throws this sometimes when listener list is being concurrently modified
}
}
}

Expand Down
10 changes: 5 additions & 5 deletions test/LoadGeneratorApp/LoadGeneratorApp.csproj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.DurableTask.Netherite.AzureFunctions" Version="1.0.3" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.7.2" />
<PackageReference Include="Microsoft.Azure.DurableTask.Netherite.AzureFunctions" Version="1.1.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.7.2" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
<ItemGroup>
Expand Down
5 changes: 5 additions & 0 deletions test/LoadGeneratorApp/Results.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static void SaveResults([ActivityTrigger] Results results)
}

static readonly string RESULTS_CONNECTION = "ResultsConnection";
static readonly string RESULTS_CONNECTION_DEFAULT = "AzureWebJobsStorage";
static readonly string RESULTFILE_CONTAINER = "results";

public static string MakeTestName(string benchmarkname)
Expand All @@ -55,6 +56,10 @@ public static string MakeTestName(string benchmarkname)
public static async Task<CloudBlobDirectory> GetOrCreateResultFileDirectory(string testname)
{
string connectionString = Environment.GetEnvironmentVariable(RESULTS_CONNECTION);
if (string.IsNullOrEmpty(connectionString))
{
connectionString = Environment.GetEnvironmentVariable(RESULTS_CONNECTION_DEFAULT);
}
CloudStorageAccount account = CloudStorageAccount.Parse(connectionString);
CloudBlobClient blobclient = account.CreateCloudBlobClient();
CloudBlobContainer container = blobclient.GetContainerReference(RESULTFILE_CONTAINER);
Expand Down
12 changes: 6 additions & 6 deletions test/LoadGeneratorApp/request.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"rate": 0.01,
"ServiceUrls": "https://functionssb2.azurewebsites.net",
"GeneratorUrl": "https://sbloadgenerator7924.azurewebsites.net",
"Duration": 3600,
"rate": 0.1,
"ServiceUrls": "url-of-service-under-test",
"GeneratorUrl": "url-of this-load-generator",
"Duration": 20,
"TimeoutSeconds": 300,
"Prefix": "seqlong-blob-af",
"Prefix": "myprefix",
"Robots": 10,
"NumberObjects": 10,
"Warmup": 0,
"Cooldown": 0,
"Operation": "TriggeredSequenceLong"
"Operation": "Wait5"
}
11 changes: 11 additions & 0 deletions test/LoadGeneratorApp/scripts/delete-function-app.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/pwsh

# read the generic parameters
. ./settings.ps1

Write-Host "Deleting Function App..."
az functionapp delete --resource-group $groupName --name $functionAppName

Write-Host "Deleting Function Plan..."
az functionapp plan delete --resource-group $groupName --name $functionAppName --yes

2 changes: 1 addition & 1 deletion test/LoadGeneratorApp/scripts/delete.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ param (
. $Settings

Write-Host "Deleting Resource Group..."
az group delete --name $groupName
az group delete --name $groupName --yes
6 changes: 3 additions & 3 deletions test/LoadGeneratorApp/scripts/deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ if ($DeployCode)
dotnet build -c $Configuration
$hostconf = (Get-Content $HostConfigurationFile | ConvertFrom-Json -Depth 32)
$hostconf.extensions.durableTask.hubName = $HubName
$hostconf | ConvertTo-Json -depth 32 | set-content "./bin/$Configuration/netcoreapp3.1/host.json"
$hostconf | ConvertTo-Json -depth 32 | set-content "./bin/$Configuration/net6.0/host.json"
}

if (-not ((az functionapp list -g $groupName --query "[].name"| ConvertFrom-Json) -contains $functionAppName))
Expand All @@ -30,7 +30,7 @@ if (-not ((az functionapp list -g $groupName --query "[].name"| ConvertFrom-Json

Write-Host "Creating $Plan Function App..."
az functionapp plan create --resource-group $groupName --name $functionAppName --location $location --sku $Plan
az functionapp create --name $functionAppName --storage-account $storageName --plan $functionAppName --resource-group $groupName --functions-version 3
az functionapp create --name $functionAppName --storage-account $storageName --plan $functionAppName --resource-group $groupName --functions-version 4
az functionapp config set -n $functionAppName -g $groupName --use-32bit-worker-process false
az functionapp config appsettings set -n $functionAppName -g $groupName --settings EventHubsConnection=$eventHubsConnectionString
az functionapp config appsettings set -n $functionAppName -g $groupName --settings ResultsConnection=$resultsConnectionString
Expand All @@ -55,7 +55,7 @@ else
if ($DeployCode)
{
# enter the directory with the binaries
Push-Location -Path bin/$Configuration/netcoreapp3.1
Push-Location -Path bin/$Configuration/net6.0

Write-Host "Publishing Code to Function App..."
func azure functionapp publish $functionAppName
Expand Down
2 changes: 1 addition & 1 deletion test/LoadGeneratorApp/settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Write-Host "Using parameters specified in settings.ps1."

# always edit this parameter before running the scripts
$name="sbloadgenerator7924"
$name="globally-unique-lowercase-alphanumeric-name-with-no-dashes"

# review these parameters before running the scripts
$location="westus2"
Expand Down
9 changes: 4 additions & 5 deletions test/PerformanceTests/PerformanceTests.csproj
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
<TargetFramework>net6.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Azure.Messaging.EventHubs" Version="5.7.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions" Version="4.0.1" />
<PackageReference Include="Microsoft.Azure.DurableTask.Core" Version="2.10.0" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.7.2" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="4.2.0" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.13" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="5.1.1" />
<PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="4.0.4" />
<PackageReference Include="Microsoft.NET.Sdk.Functions" Version="4.1.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\src\DurableTask.Netherite.AzureFunctions\DurableTask.Netherite.AzureFunctions.csproj" />
Expand Down
4 changes: 2 additions & 2 deletions test/PerformanceTests/local.settings.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "Should be ignored because we have the environment variable set",
"EventHubsConnection": "Should be ignored because we have the environment variable set",
"AzureWebJobsStorage": "UseDevelopmentStorage=true;",
"EventHubsConnection": "MemoryF",
"FUNCTIONS_WORKER_RUNTIME": "dotnet"
}
}
File renamed without changes.
11 changes: 11 additions & 0 deletions test/PerformanceTests/scripts/delete-function-app.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/pwsh

# read the generic parameters
. ./settings.ps1

Write-Host "Deleting Function App..."
az functionapp delete --resource-group $groupName --name $functionAppName

Write-Host "Deleting Function Plan..."
az functionapp plan delete --resource-group $groupName --name $functionAppName --yes

6 changes: 3 additions & 3 deletions test/PerformanceTests/scripts/deploy.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ if ($DeployCode)
$hostconf.extensions.durableTask | Add-Member -NotePropertyName "maxConcurrentActivityFunctions" -NotePropertyValue $MaxA
}

$hostconf | ConvertTo-Json -depth 32 | set-content "./bin/$Configuration/netcoreapp3.1/host.json"
$hostconf | ConvertTo-Json -depth 32 | set-content "./bin/$Configuration/net6.0/host.json"
}

if (-not ((az functionapp list -g $groupName --query "[].name"| ConvertFrom-Json) -contains $functionAppName))
Expand All @@ -39,7 +39,7 @@ if (-not ((az functionapp list -g $groupName --query "[].name"| ConvertFrom-Json

Write-Host "Creating $Plan Function App..."
az functionapp plan create --resource-group $groupName --name $functionAppName --location $location --sku $Plan
az functionapp create --name $functionAppName --storage-account $storageName --plan $functionAppName --resource-group $groupName --functions-version 3
az functionapp create --name $functionAppName --storage-account $storageName --plan $functionAppName --resource-group $groupName --functions-version 4
az functionapp config set -n $functionAppName -g $groupName --use-32bit-worker-process false
az functionapp config appsettings set -n $functionAppName -g $groupName --settings EventHubsConnection=$eventHubsConnectionString
az functionapp config appsettings set -n $functionAppName -g $groupName --settings CorpusConnection=$corpusConnectionString
Expand All @@ -64,7 +64,7 @@ else
if ($DeployCode)
{
# enter the directory with the binaries
Push-Location -Path bin/$Configuration/netcoreapp3.1
Push-Location -Path bin/$Configuration/net6.0

Write-Host "Publishing Code to Function App..."
func azure functionapp publish $functionAppName
Expand Down
2 changes: 1 addition & 1 deletion test/PerformanceTests/scripts/run.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Write-Host Building $Configuration Configuration...
dotnet build -c $Configuration

# enter the directory with the binaries
Push-Location -Path bin/$Configuration/netcoreapp3.1
Push-Location -Path bin/$Configuration/net6.0

# look up the two connection strings and assign them to the respective environment variables
$Env:AzureWebJobsStorage = (az storage account show-connection-string --name $storageName --resource-group $groupName | ConvertFrom-Json).connectionString
Expand Down
2 changes: 1 addition & 1 deletion test/PerformanceTests/scripts/runcmd.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $Env:AzureWebJobsStorage = (az storage account show-connection-string --name $st
$Env:EventHubsConnection = (az eventhubs namespace authorization-rule keys list --resource-group $groupName --namespace-name $namespaceName --name RootManageSharedAccessKey | ConvertFrom-Json).primaryConnectionString

# enter the directory with the binaries
Push-Location -Path bin/$Configuration/netcoreapp3.1
Push-Location -Path bin/$Configuration/net6.0

# start an interactive windows cmd shell in the deployment directory
cmd
Expand Down

0 comments on commit 38b75d7

Please sign in to comment.