33 * Licensed under the MIT License. See License.txt in the project root for license information.
44 *--------------------------------------------------------------------------------------------*/
55
6- import { type NameValuePair , type Site , type SiteConfig , type WebSiteManagementClient } from '@azure/arm-appservice' ;
6+ import { type FunctionsDeploymentStorageAuthentication , type NameValuePair , type Site , type SiteConfig , type WebSiteManagementClient } from '@azure/arm-appservice' ;
77import { type Identity } from '@azure/arm-resources' ;
88import { BlobServiceClient } from '@azure/storage-blob' ;
99import { ParsedSite , WebsiteOS , type CustomLocation , type IAppServiceWizardContext } from '@microsoft/vscode-azext-azureappservice' ;
@@ -98,11 +98,7 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWi
9898 storage : {
9999 type : 'blobContainer' ,
100100 value : `${ context . storageAccount ?. primaryEndpoints ?. blob } app-package-${ context . newSiteName ?. substring ( 0 , 32 ) } -${ randomUtils . getRandomHexString ( 7 ) } ` ,
101- authentication : {
102- userAssignedIdentityResourceId : undefined ,
103- type : 'StorageAccountConnectionString' ,
104- storageAccountConnectionStringName : 'DEPLOYMENT_STORAGE_CONNECTION_STRING'
105- }
101+ authentication : createDeploymentStorageAuthentication ( context )
106102 }
107103 } ,
108104 runtime : {
@@ -118,6 +114,15 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWi
118114 }
119115
120116 return site ;
117+
118+ function createDeploymentStorageAuthentication ( context : IFlexFunctionAppWizardContext ) : FunctionsDeploymentStorageAuthentication {
119+ const hasManagedIdentity : boolean = ! ! context . managedIdentity ;
120+ return {
121+ userAssignedIdentityResourceId : hasManagedIdentity ? context . managedIdentity ?. id : undefined ,
122+ type : hasManagedIdentity ? 'UserAssignedIdentity' : 'StorageAccountConnectionString' ,
123+ storageAccountConnectionStringName : hasManagedIdentity ? undefined : 'DEPLOYMENT_STORAGE_CONNECTION_STRING' ,
124+ } ;
125+ }
121126 }
122127
123128 private async createNewSite ( context : IFunctionAppWizardContext , stack ?: FullFunctionAppStack ) : Promise < Site > {
@@ -192,7 +197,8 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStep<IFunctionAppWi
192197 name : contentShareKey ,
193198 value : getNewFileShareName ( nonNullProp ( context , 'newSiteName' ) )
194199 } ) ;
195- } else if ( isFlex ) {
200+ // only add this setting for flex apps, if we're not using managed identity
201+ } else if ( isFlex && ! context . managedIdentity ) {
196202 appSettings . push ( {
197203 name : 'DEPLOYMENT_STORAGE_CONNECTION_STRING' ,
198204 value : storageConnectionString
0 commit comments