|
5 | 5 |
|
6 | 6 | import { type NameValuePair, type Site, type SiteConfig, type WebSiteManagementClient } from '@azure/arm-appservice'; |
7 | 7 | import { createHttpHeaders, createPipelineRequest, type RequestBodyType } from '@azure/core-rest-pipeline'; |
| 8 | +import { BlobServiceClient } from '@azure/storage-blob'; |
8 | 9 | import { ParsedSite, WebsiteOS, type CustomLocation, type IAppServiceWizardContext } from '@microsoft/vscode-azext-azureappservice'; |
9 | 10 | import { LocationListStep, createGenericClient, type AzExtPipelineResponse, type AzExtRequestPrepareOptions } from '@microsoft/vscode-azext-azureutils'; |
10 | 11 | import { AzureWizardExecuteStep, parseError, randomUtils } from '@microsoft/vscode-azext-utils'; |
@@ -245,6 +246,9 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWi |
245 | 246 | const client = await createGenericClient(context, context); |
246 | 247 | const result = await client.sendRequest(createPipelineRequest(options)) as AzExtPipelineResponse; |
247 | 248 | if (result && result.status >= 200 && result.status < 300) { |
| 249 | + const site = result.parsedBody as Site & { properties: FlexFunctionAppProperties }; |
| 250 | + const storageConnectionString: string = (await getStorageConnectionString(context)).connectionString; |
| 251 | + await tryCreateStorageContainer(site, storageConnectionString); |
248 | 252 | const client: WebSiteManagementClient = await createWebSiteClient(context); |
249 | 253 | // the payload for the new API version "2023-12-01" is incompatiable with our current SiteClient so get the old payload |
250 | 254 | try { |
@@ -275,6 +279,18 @@ function getSiteKind(context: IAppServiceWizardContext): string { |
275 | 279 | return kind; |
276 | 280 | } |
277 | 281 |
|
| 282 | +// storage container is needed for flex deployment, but it is not created automatically |
| 283 | +async function tryCreateStorageContainer(site: Site & { properties: FlexFunctionAppProperties }, storageConnectionString: string): Promise<void> { |
| 284 | + const blobClient = BlobServiceClient.fromConnectionString(storageConnectionString); |
| 285 | + const containerName = site.properties?.functionAppConfig?.deployment.storage.value.split('/').pop(); |
| 286 | + if (containerName) { |
| 287 | + const client = blobClient.getContainerClient(containerName); |
| 288 | + if (!await client.exists()) { |
| 289 | + await blobClient.createContainer(containerName); |
| 290 | + } |
| 291 | + } |
| 292 | +} |
| 293 | + |
278 | 294 | type FlexFunctionAppProperties = { |
279 | 295 | containerSize?: number, |
280 | 296 | sku?: 'FlexConsumption', |
|
0 commit comments