Skip to content

Instantly share code, notes, and snippets.

@ChristianEder
Created July 31, 2020 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ChristianEder/42f57e27d8b6ab75d299722764704d57 to your computer and use it in GitHub Desktop.
Save ChristianEder/42f57e27d8b6ab75d299722764704d57 to your computer and use it in GitHub Desktop.
private Input<string> GetSignedBlobUrl(Blob blob, Account storageAccount)
{
const string signatureExpiration = "2100-01-01";
var url = Output.All(new[] { storageAccount.Name, storageAccount.PrimaryConnectionString, blob.StorageContainerName, blob.Name })
.Apply(async (parameters) =>
{
var accountName = parameters[0];
var connectionString = parameters[1];
var containerName = parameters[2];
var blobName = parameters[3];
var sas = await GetAccountBlobContainerSAS.InvokeAsync(new GetAccountBlobContainerSASArgs
{
ConnectionString = connectionString,
ContainerName = containerName,
Start = "2020-07-20",
Expiry = signatureExpiration,
Permissions = new Pulumi.Azure.Storage.Inputs.GetAccountBlobContainerSASPermissionsArgs
{
Read = true,
Write = false,
Delete = false,
List = false,
Add = false,
Create = false
}
});
return $"https://{accountName}.blob.core.windows.net/{containerName}/{blobName}{sas.Sas}";
});
return url;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment