@@ -147,15 +147,24 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStepWithActivityOut
147147 private async getNewSiteConfig ( context : IFunctionAppWizardContext , stack ?: FullFunctionAppStack ) : Promise < SiteConfig > {
148148 let newSiteConfig : SiteConfig = { } ;
149149
150- const storageConnectionString : string = ( await getStorageConnectionString ( context ) ) . connectionString ;
150+ const isElasticPremium : boolean = context . plan ?. sku ?. family ?. toLowerCase ( ) === 'ep' ;
151+ const isConsumption : boolean = context . plan ?. sku ?. family ?. toLowerCase ( ) === 'y' ;
152+ // no stack means it's a flex app
153+ const isFlex : boolean = ! stack ;
154+
155+ // Only fetch the storage connection string when it's actually needed.
156+ // It's not needed for flex + managed identity since all storage settings use service URIs.
157+ const needsConnectionString : boolean = ! ( isFlex && context . managedIdentity ) ;
158+ const storageConnectionString : string | undefined = needsConnectionString ?
159+ ( await getStorageConnectionString ( context ) ) . connectionString : undefined ;
151160
152161 let appSettings : NameValuePair [ ] = [ ] ;
153162 if ( context . managedIdentity ) {
154163 appSettings . push ( ...createAzureWebJobsStorageManagedIdentitySettings ( context ) ) ;
155164 } else {
156165 appSettings . push ( {
157166 name : ConnectionKey . Storage ,
158- value : storageConnectionString
167+ value : nonNullProp ( { storageConnectionString } , 'storageConnectionString' )
159168 } ) ;
160169 }
161170
@@ -176,20 +185,16 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStepWithActivityOut
176185 if ( context . version === FuncVersion . v1 ) {
177186 appSettings . push ( {
178187 name : 'AzureWebJobsDashboard' ,
179- value : storageConnectionString
188+ value : nonNullProp ( { storageConnectionString } , 'storageConnectionString' )
180189 } ) ;
181190 }
182191
183- const isElasticPremium : boolean = context . plan ?. sku ?. family ?. toLowerCase ( ) === 'ep' ;
184- const isConsumption : boolean = context . plan ?. sku ?. family ?. toLowerCase ( ) === 'y' ;
185- // no stack means it's a flex app
186- const isFlex : boolean = ! stack ;
187192 if ( isConsumption || isElasticPremium ) {
188193 // WEBSITE_CONTENT* settings are added for consumption/premium plans, but not dedicated
189194 // https://github.com/microsoft/vscode-azurefunctions/issues/1702
190195 appSettings . push ( {
191196 name : contentConnectionStringKey ,
192- value : storageConnectionString
197+ value : nonNullProp ( { storageConnectionString } , 'storageConnectionString' )
193198 } ) ;
194199 appSettings . push ( {
195200 name : contentShareKey ,
@@ -199,7 +204,7 @@ export class FunctionAppCreateStep extends AzureWizardExecuteStepWithActivityOut
199204 } else if ( isFlex && ! context . managedIdentity ) {
200205 appSettings . push ( {
201206 name : 'DEPLOYMENT_STORAGE_CONNECTION_STRING' ,
202- value : storageConnectionString
207+ value : nonNullProp ( { storageConnectionString } , 'storageConnectionString' )
203208 } ) ;
204209 }
205210
0 commit comments