Test infrastructure for C# Azure Function testing (#2055)

Add support for function tests and the ability to run them against either real Azure Storage or the Azurite emulator.

See follow-up PR #2032 for actual usage.
This commit is contained in:
George Pollard
2022-06-17 09:50:02 +12:00
committed by GitHub
parent e9147ba9a7
commit cdec3c9e8d
17 changed files with 594 additions and 14 deletions

View File

@ -45,7 +45,7 @@ public class Containers : IContainers {
if (client is null)
return null;
return new Uri($"{GetUrl(client.AccountName)}{container}/{name}");
return new Uri($"{_storage.GetBlobEndpoint(client.AccountName)}{container}/{name}");
}
public async Async.Task<BinaryData?> GetBlob(Container container, string name, StorageType storageType) {
@ -93,14 +93,10 @@ public class Containers : IContainers {
return null;
}
var storageKeyCredential = new StorageSharedKeyCredential(accountName, accountKey);
var accountUrl = GetUrl(accountName);
var accountUrl = _storage.GetBlobEndpoint(accountName);
return new BlobServiceClient(accountUrl, storageKeyCredential);
}
private static Uri GetUrl(string accountName) {
return new Uri($"https://{accountName}.blob.core.windows.net/");
}
public async Async.Task<Uri?> GetFileSasUrl(Container container, string name, StorageType storageType, BlobSasPermissions permissions, TimeSpan? duration = null) {
var client = await FindContainer(container, storageType) ?? throw new Exception($"unable to find container: {container.ContainerName} - {storageType}");
@ -194,4 +190,3 @@ public class Containers : IContainers {
return await client.GetBlobClient(name).ExistsAsync();
}
}