|
8 | 8 | $UseCoreToolsBuildFromIntegrationTests
|
9 | 9 | )
|
10 | 10 |
|
| 11 | +function NewTaskHubName |
| 12 | +{ |
| 13 | + param( |
| 14 | + [int]$Length = 45 |
| 15 | + ) |
| 16 | + |
| 17 | + <# |
| 18 | + Task hubs are identified by a name that conforms to these rules: |
| 19 | + - Contains only alphanumeric characters |
| 20 | + - Starts with a letter |
| 21 | + - Has a minimum length of 3 characters, maximum length of 45 characters |
| 22 | +
|
| 23 | + doc: According to the documentation here https://docs.microsoft.com/en-us/azure/azure-functions/durable/durable-functions-task-hubs?tabs=csharp |
| 24 | + #> |
| 25 | + |
| 26 | + $min = 20 |
| 27 | + $max = 45 |
| 28 | + |
| 29 | + if ($length -lt $min -or $Length -gt $max) |
| 30 | + { |
| 31 | + throw "Length must be between $min and $max characters. Provided value: $length" |
| 32 | + } |
| 33 | + |
| 34 | + $letters = 'a'..'z' + 'A'..'Z' |
| 35 | + $numbers = 0..9 |
| 36 | + $alphanumeric = $letters + $numbers |
| 37 | + |
| 38 | + # First value is a letter |
| 39 | + $sb = [System.Text.StringBuilder]::new() |
| 40 | + $value = $letters | Get-Random |
| 41 | + $sb.Append($value) | Out-Null |
| 42 | + |
| 43 | + # Add the date and time as part of the name. This way, we can delete older versions. |
| 44 | + # Example: 202104251929 is for 2021-04-25:1929 (this value is 12 characters long) |
| 45 | + $value = Get-Date -Format "yyyyMMddHHmm" |
| 46 | + $sb.Append($value) | Out-Null |
| 47 | + |
| 48 | + # The remaining of the characters are random alphanumeric values |
| 49 | + for ($index = 13; $index -lt $length; $index++) |
| 50 | + { |
| 51 | + $value = $alphanumeric | Get-Random |
| 52 | + $sb.Append($value) | Out-Null |
| 53 | + } |
| 54 | + |
| 55 | + $sb.ToString() |
| 56 | +} |
| 57 | + |
| 58 | +$taskHubName = NewTaskHubName -Length 45 |
| 59 | + |
11 | 60 | $FUNC_RUNTIME_VERSION = '3'
|
12 | 61 | $NETCOREAPP_VERSION = '3.1'
|
13 | 62 | $POWERSHELL_VERSION = '7'
|
@@ -68,6 +117,7 @@ if (-not $UseCoreToolsBuildFromIntegrationTests.IsPresent)
|
68 | 117 |
|
69 | 118 | Write-Host "Starting Functions Host..."
|
70 | 119 |
|
| 120 | +$Env:TestTaskHubName = $taskHubName |
71 | 121 | $Env:FUNCTIONS_WORKER_RUNTIME = "powershell"
|
72 | 122 | $Env:FUNCTIONS_WORKER_RUNTIME_VERSION = $POWERSHELL_VERSION
|
73 | 123 | $Env:AZURE_FUNCTIONS_ENVIRONMENT = "development"
|
|
0 commit comments