Skip to content

Commit

Permalink
Merge pull request pulumi#932 from pulumi/vl/926
Browse files Browse the repository at this point in the history
Add support for AzureWebJobsStorage azure-cs-functions
  • Loading branch information
Vivek Lakshmanan committed Mar 4, 2021
2 parents 26dc0e7 + ce021a4 commit 8945828
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions azure-cs-functions/FunctionsStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ public FunctionsStack()
{
AppSettings = new[]
{
new NameValuePairArgs{
Name = "AzureWebJobsStorage",
Value = GetConnectionString(resourceGroup.Name, storageAccount.Name),
},
new NameValuePairArgs{
Name = "runtime",
Value = "python",
Expand Down Expand Up @@ -128,4 +132,28 @@ private static Output<string> SignedBlobReadUrl(Blob blob, BlobContainer contain
return Output.Format($"https://{accountName}.blob.core.windows.net/{containerName}/{blobName}?{blobSAS.Result.ServiceSasToken}");
});
}

private static Output<string> GetConnectionString(Input<string> resourceGroupName, Input<string> accountName)
{
// Retrieve the primary storage account key.
var storageAccountKeys = Output.All<string>(resourceGroupName, accountName).Apply(t =>
{
var resourceGroupName = t[0];
var accountName = t[1];
return ListStorageAccountKeys.InvokeAsync(
new ListStorageAccountKeysArgs
{
ResourceGroupName = resourceGroupName,
AccountName = accountName
});
});
return storageAccountKeys.Apply(keys =>
{
var primaryStorageKey = keys.Keys[0].Value;
// Build the connection string to the storage account.
return Output.Format($"DefaultEndpointsProtocol=https;AccountName={accountName};AccountKey={primaryStorageKey}");
});
}

}

0 comments on commit 8945828

Please sign in to comment.