Remove custom implementations of signedBlobReadUrl
MODIFY
azure-ts-appservice-devops/infra/index.ts
azure-ts-appservice-devops/infra/index.ts
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
-import { signedBlobReadUrl } from "./sas";
// use first 10 characters of the stackname as prefix for resource names
const prefix = pulumi.getStack().substring(0, 9);
@@ -53,7 +52,7 @@ const blob = new azure.storage.ZipBlob(`${prefix}-b`, {
content: new pulumi.asset.FileArchive("../src/bin/Debug/netcoreapp2.1/publish")
});
-const codeBlobUrl = signedBlobReadUrl(blob, storageAccount, storageContainer);
+const codeBlobUrl = azure.storage.signedBlobReadUrl(blob, storageAccount);
const appInsights = new azure.appinsights.Insights(`${prefix}-ai`, {
...resourceGroupArgs,

MODIFY
azure-ts-appservice-devops/infra/package.json
azure-ts-appservice-devops/infra/package.json
},
"dependencies": {
"@pulumi/pulumi": "latest",
- "@pulumi/azure": "latest",
- "azure-storage": "^2.9.0-preview"
+ "@pulumi/azure": "latest"
}
}

DELETE
azure-ts-appservice-devops/infra/sas.ts
-import * as pulumi from "@pulumi/pulumi";
-import * as azure from "@pulumi/azure";
-
-import * as azurestorage from "azure-storage";
-
-// Given an Azure blob, create a SAS URL that can read it.
-export function signedBlobReadUrl(
- blob: azure.storage.Blob | azure.storage.ZipBlob,
- account: azure.storage.Account,
- container: azure.storage.Container,
-): pulumi.Output<string> {
- // Choose a fixed, far-future expiration date for signed blob URLs.
- // The shared access signature (SAS) we generate for the Azure storage blob must remain valid for as long as the
- // Function App is deployed, since new instances will download the code on startup. By using a fixed date, rather
- // than (e.g.) "today plus ten years", the signing operation is idempotent.
- const signatureExpiration = new Date(2100, 1);
-
- return pulumi.all([
- account.primaryConnectionString,
- container.name,
- blob.name,
- ]).apply(([connectionString, containerName, blobName]) => {
- let blobService = new azurestorage.BlobService(connectionString);
- let signature = blobService.generateSharedAccessSignature(
- containerName,
- blobName,
- {
- AccessPolicy: {
- Expiry: signatureExpiration,
- Permissions: azurestorage.BlobUtilities.SharedAccessPermissions.READ,
- },
- }
- );
-
- return blobService.getUrl(containerName, blobName, signature);
- });
-}

MODIFY
azure-ts-appservice-devops/infra/tsconfig.json
azure-ts-appservice-devops/infra/tsconfig.json
"strictNullChecks": true
},
"files": [
- "index.ts",
- "sas.ts"
+ "index.ts"
]
}

MODIFY
azure-ts-appservice/index.ts
azure-ts-appservice/index.ts
import * as pulumi from "@pulumi/pulumi";
import * as azure from "@pulumi/azure";
-import { signedBlobReadUrl } from "./sas";
// use first 10 characters of the stackname as prefix for resource names
const prefix = pulumi.getStack().substring(0, 9);
@@ -51,7 +50,7 @@ const blob = new azure.storage.ZipBlob(`${prefix}-b`, {
content: new pulumi.asset.FileArchive("wwwroot")
});
-const codeBlobUrl = signedBlobReadUrl(blob, storageAccount, storageContainer);
+const codeBlobUrl = azure.storage.signedBlobReadUrl(blob, storageAccount);
const appInsights = new azure.appinsights.Insights(`${prefix}-ai`, {
...resourceGroupArgs,

MODIFY
azure-ts-appservice/package.json
azure-ts-appservice/package.json
},
"dependencies": {
"@pulumi/azure": "latest",
- "@pulumi/pulumi": "latest",
- "azure-storage": "^2.9.0-preview"
+ "@pulumi/pulumi": "latest"
}
}

DELETE
azure-ts-appservice/sas.ts
-import * as pulumi from "@pulumi/pulumi";
-import * as azure from "@pulumi/azure";
-
-import * as azurestorage from "azure-storage";
-
-// Given an Azure blob, create a SAS URL that can read it.
-export function signedBlobReadUrl(
- blob: azure.storage.Blob | azure.storage.ZipBlob,
- account: azure.storage.Account,
- container: azure.storage.Container,
-): pulumi.Output<string> {
- // Choose a fixed, far-future expiration date for signed blob URLs.
- // The shared access signature (SAS) we generate for the Azure storage blob must remain valid for as long as the
- // Function App is deployed, since new instances will download the code on startup. By using a fixed date, rather
- // than (e.g.) "today plus ten years", the signing operation is idempotent.
- const signatureExpiration = new Date(2100, 1);
-
- return pulumi.all([
- account.primaryConnectionString,
- container.name,
- blob.name,
- ]).apply(([connectionString, containerName, blobName]) => {
- let blobService = new azurestorage.BlobService(connectionString);
- let signature = blobService.generateSharedAccessSignature(
- containerName,
- blobName,
- {
- AccessPolicy: {
- Expiry: signatureExpiration,
- Permissions: azurestorage.BlobUtilities.SharedAccessPermissions.READ,
- },
- }
- );
-
- return blobService.getUrl(containerName, blobName, signature);
- });
-}

MODIFY
azure-ts-appservice/tsconfig.json
azure-ts-appservice/tsconfig.json
"strictNullChecks": true
},
"files": [
- "index.ts",
- "sas.ts"
+ "index.ts"
]
}

MODIFY
azure-ts-functions/azureFunction.ts
azure-ts-functions/azureFunction.ts
@@ -3,8 +3,6 @@ import * as azure from "@pulumi/azure";
import * as azurefunctions from "azure-functions-ts-essentials";
-import { signedBlobReadUrl } from "./sas";
-
export type Context = azurefunctions.Context;
export type HttpRequest = azurefunctions.HttpRequest;
export * from "azure-functions-ts-essentials";
@@ -92,7 +90,7 @@ export class HttpFunction extends pulumi.ComponentResource {
content: new pulumi.asset.AssetArchive(blobContent(name, handler)),
}, parentArgs);
- this.codeBlobUrl = signedBlobReadUrl(this.blob, this.storageAccount, this.storageContainer);
+ this.codeBlobUrl = azure.storage.signedBlobReadUrl(this.blob, this.storageAccount);
this.appServicePlan = new azure.appservice.Plan(`${name}-p`, {
...resourceGroupArgs,

MODIFY
azure-ts-functions/package.json
azure-ts-functions/package.json
},
"dependencies": {
"@pulumi/azure": "latest",
- "@pulumi/pulumi": "latest",
- "azure-storage": "^2.9.0-preview"
+ "@pulumi/pulumi": "latest"
}
}

DELETE
azure-ts-functions/sas.ts
-import * as pulumi from "@pulumi/pulumi";
-import * as azure from "@pulumi/azure";
-
-import * as azurestorage from "azure-storage";
-
-// Given an Azure blob, create a SAS URL that can read it.
-export function signedBlobReadUrl(
- blob: azure.storage.Blob | azure.storage.ZipBlob,
- account: azure.storage.Account,
- container: azure.storage.Container,
-): pulumi.Output<string> {
- // Choose a fixed, far-future expiration date for signed blob URLs.
- // The shared access signature (SAS) we generate for the Azure storage blob must remain valid for as long as the
- // Function App is deployed, since new instances will download the code on startup. By using a fixed date, rather
- // than (e.g.) "today plus ten years", the signing operation is idempotent.
- const signatureExpiration = new Date(2100, 1);
-
- return pulumi.all([
- account.primaryConnectionString,
- container.name,
- blob.name,
- ]).apply(([connectionString, containerName, blobName]) => {
- let blobService = new azurestorage.BlobService(connectionString);
- let signature = blobService.generateSharedAccessSignature(
- containerName,
- blobName,
- {
- AccessPolicy: {
- Expiry: signatureExpiration,
- Permissions: azurestorage.BlobUtilities.SharedAccessPermissions.READ,
- },
- }
- );
-
- return blobService.getUrl(containerName, blobName, signature);
- });
-}

MODIFY
azure-ts-functions/tsconfig.json
azure-ts-functions/tsconfig.json
},
"files": [
"azureFunction.ts",
- "index.ts",
- "sas.ts",
+ "index.ts"
]
}

Remove custom implementations of signedBlobReadUrl (#313)