diff --git a/vsts/E2ETestsSetup/e2eTestsSetup.ps1 b/vsts/E2ETestsSetup/e2eTestsSetup.ps1 index de6a9edf0e..da62c6faf8 100644 --- a/vsts/E2ETestsSetup/e2eTestsSetup.ps1 +++ b/vsts/E2ETestsSetup/e2eTestsSetup.ps1 @@ -58,7 +58,16 @@ $rgExists = az group exists --name $ResourceGroup if ($rgExists -eq "False") { Write-Host "`nCreating resource group $ResourceGroup in $Region" - az group create --name $ResourceGroup --location $Region --output none + + # Tagged as part of the creation itself, not afterwards: the scheduled cleanup in + # Azure/azure-iot-sdk-csharp vsts/resource-group-cleanup.yaml (which deletes leftover + # 'javasdkgate*' groups as well as 'dotnetsdkgate*' ones) uses 'CreatedOn' to tell a leftover + # group from one whose gate run is still in flight. Tagging in a second, separate call would + # leave a window where a run that dies in between produces an untagged group. That cleanup + # still reclaims such a group, but only via the slower 24-hour first-observed fallback rather + # than the 3-hour path. A single tag is passed here on purpose -- under the AzureCLI@2 task, + # '--tags' with several key=value arguments collapses them into one tag value. + az group create --name $ResourceGroup --location $Region --tags "CreatedOn=$([datetime]::UtcNow.ToString('o'))" --output none } $resourceGroupId = az group show -n $ResourceGroup --query id --out tsv