in src/commands/registries/azure/DockerSiteCreateStep.ts [60:130]
private async getNewSiteConfig(context: IAppServiceContainerWizardContext): Promise<WebSiteManagementModels.SiteConfig> {
const registryTI: RegistryTreeItemBase = this.node.parent.parent;
let username: string | undefined;
let password: string | undefined;
let registryUrl: string | undefined;
const appSettings: WebSiteManagementModels.NameValuePair[] = [];
// Scenarios:
// ACR -> App Service, NOT Arc App Service. Use managed service identity.
if (registryTI instanceof AzureRegistryTreeItem && !context.customLocation) {
appSettings.push({ name: 'DOCKER_ENABLE_CI', value: 'true' });
// Don't need an image, username, or password--just create an empty web app to assign permissions and then configure with an image
// `DockerAssignAcrPullRoleStep` handles it after that
return {
acrUseManagedIdentityCreds: true,
appSettings
};
}
// ACR -> Arc App Service. Use regular auth. Same as any V2 registry but different way of getting auth.
else if (registryTI instanceof AzureRegistryTreeItem && context.customLocation) {
const cred = await registryTI.tryGetAdminCredentials(context);
if (!cred?.username || !cred?.passwords?.[0]?.value) {
throw new Error(localize('vscode-docker.commands.registries.azure.dockersitecreatestep.notAdminEnabled', 'Azure App service deployment on Azure Arc only supports running images from Azure Container Registries with admin enabled'));
}
username = cred.username;
password = cred.passwords[0].value;
registryUrl = registryTI.baseUrl;
}
// Docker Hub -> App Service *OR* Arc App Service
else if (registryTI instanceof DockerHubNamespaceTreeItem) {
username = registryTI.parent.username;
password = await registryTI.parent.getPassword();
registryUrl = 'https://index.docker.io';
}
// Generic registry -> App Service *OR* Arc App Service
else if (registryTI instanceof DockerV2RegistryTreeItemBase) {
if (registryTI instanceof GenericDockerV2RegistryTreeItem) {
username = registryTI.cachedProvider.username;
password = await getRegistryPassword(registryTI.cachedProvider);
} else {
throw new RangeError(localize('vscode-docker.commands.registries.azure.deployImage.unrecognizedNodeTypeA', 'Unrecognized node type "{0}"', registryTI.constructor.name));
}
registryUrl = registryTI.baseUrl;
} else {
throw new RangeError(localize('vscode-docker.commands.registries.azure.deployImage.unrecognizedNodeTypeB', 'Unrecognized node type "{0}"', registryTI.constructor.name));
}
if (username && password) {
appSettings.push({ name: "DOCKER_REGISTRY_SERVER_USERNAME", value: username });
appSettings.push({ name: "DOCKER_REGISTRY_SERVER_PASSWORD", value: password });
}
if (registryUrl) {
appSettings.push({ name: 'DOCKER_REGISTRY_SERVER_URL', value: registryUrl });
}
if (context.webSitesPort) {
appSettings.push({ name: "WEBSITES_PORT", value: context.webSitesPort.toString() });
}
const linuxFxVersion = `DOCKER|${this.node.fullTag}`;
return {
linuxFxVersion,
appSettings
};
}