Skip to content

Commit

Permalink
Update azure-java-appservice-sql to Output-versioned invokes (pulumi#…
Browse files Browse the repository at this point in the history
  • Loading branch information
t0yv0 committed Sep 8, 2022
1 parent 15f0857 commit 4562be3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 19 deletions.
2 changes: 1 addition & 1 deletion azure-java-appservice-sql/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Provisions Azure SQL Database and Azure Application Insights to be used in combi

```
$ pulumi config set azure-native:location westus
$ pulumi config set azure-java-appservice-sql:sqlPassword <value>
$ pulumi config set azure-java-appservice-sql:sqlPassword <value> --secret
```

1. Run `pulumi up` to preview and deploy changes:
Expand Down
39 changes: 21 additions & 18 deletions azure-java-appservice-sql/src/main/java/appservice/App.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,24 +134,27 @@ private static void stack(Context ctx) {
ctx.export("endpoint", Output.format("https://%s", app.defaultHostName()));
}

private static Output<String> getSASToken(Output<String> storageAccountName, Output<String> storageContainerName,
Output<String> blobName, Output<String> resourceGroupName) {
var blobSAS = Output.tuple(resourceGroupName, storageAccountName, storageContainerName).apply(t -> Output.of(
StorageFunctions.listStorageAccountServiceSAS(
ListStorageAccountServiceSASArgs.builder().resourceGroupName(t.t1)
.accountName(t.t2)
.protocols(HttpProtocol.Https)
.sharedAccessStartTime("2022-01-01")
.sharedAccessExpiryTime("2030-01-01")
.resource(SignedResource.C)
.permissions(Permissions.R)
.canonicalizedResource(String.format("/blob/%s/%s", t.t2, t.t3))
.contentType("application/json")
.cacheControl("max-age=5")
.contentDisposition("inline")
.contentEncoding("deflate")
.build())));
private static Output<String> getSASToken(Output<String> storageAccount,
Output<String> storageContainer,
Output<String> blob,
Output<String> resourceGroup) {
var blobSAS = StorageFunctions.listStorageAccountServiceSAS(ListStorageAccountServiceSASArgs.builder()
.resourceGroupName(resourceGroup)
.accountName(storageAccount)
.protocols(HttpProtocol.Https)
.sharedAccessStartTime("2022-01-01")
.sharedAccessExpiryTime("2030-01-01")
.resource(SignedResource.C)
.permissions(Permissions.R)
.canonicalizedResource(String.format("/blob/%s/%s", storageAccount, storageContainer))
.contentType("application/json")
.cacheControl("max-age=5")
.contentDisposition("inline")
.contentEncoding("deflate")
.build()
);
var token = blobSAS.applyValue(ListStorageAccountServiceSASResult::serviceSasToken);
return Output.format("https://%s.blob.core.windows.net/%s/%s?%s", storageAccountName, storageContainerName, blobName, token);
return Output.format("https://%s.blob.core.windows.net/%s/%s?%s",
storageAccount, storageContainer, blob, token);
}
}

0 comments on commit 4562be3

Please sign in to comment.