Skip to content

Commit 7519690

Browse files
authored
Configure deployment mi (#4494)
1 parent 211bed4 commit 7519690

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

src/commands/createFunctionApp/FunctionAppCreateStep.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
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';
77
import { type Identity } from '@azure/arm-resources';
88
import { BlobServiceClient } from '@azure/storage-blob';
99
import { 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

Comments
 (0)