-
Notifications
You must be signed in to change notification settings - Fork 136
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Dotnet Isolated runtime specific dependencies and cleanup durableUtils
#3597
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
c4d942b
use more generic durable dependency check
MicroFish91 6817fa9
add logic for installing new dotnet isolated deps
MicroFish91 90bbb12
correct package names
MicroFish91 6608cae
remove extra durableUtils prefix
MicroFish91 01e5edf
remove unneeded exports
MicroFish91 9b0c999
missed extraneous resolve from refactor
MicroFish91 03bacc1
amend comment
MicroFish91 1e809ad
change in process var names
MicroFish91 088a7c7
update comment with issue
MicroFish91 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,11 +19,13 @@ import { venvUtils } from "./venvUtils"; | |
import { findFiles } from "./workspace"; | ||
|
||
export namespace durableUtils { | ||
export const dotnetDfSqlPackage: string = 'Microsoft.DurableTask.SqlServer.AzureFunctions'; | ||
export const dotnetDfNetheritePackage: string = 'Microsoft.Azure.DurableTask.Netherite.AzureFunctions'; | ||
export const dotnetDfBasePackage: string = 'Microsoft.Azure.WebJobs.Extensions.DurableTask'; | ||
export const nodeDfPackage: string = 'durable-functions'; | ||
export const pythonDfPackage: string = 'azure-functions-durable'; | ||
const dotnetLtsDfSqlPackage: string = 'Microsoft.DurableTask.SqlServer.AzureFunctions'; | ||
const dotnetIsolatedDfSqlPackage: string = 'Microsoft.Azure.Functions.Worker.Extensions.DurableTask.SqlServer'; | ||
const dotnetLtsDfNetheritePackage: string = 'Microsoft.Azure.DurableTask.Netherite.AzureFunctions'; | ||
const dotnetIsolatedDfNetheritePackage: string = 'Microsoft.Azure.Functions.Worker.Extensions.DurableTask.Netherite'; | ||
const dotnetLtsDfBasePackage: string = 'Microsoft.Azure.WebJobs.Extensions.DurableTask'; | ||
const nodeDfPackage: string = 'durable-functions'; | ||
const pythonDfPackage: string = 'azure-functions-durable'; | ||
|
||
export function requiresDurableStorageSetup(context: IFunctionWizardContext): boolean { | ||
return !!context.functionTemplate && templateRequiresDurableStorageSetup(context.functionTemplate.id, context.language) && !context.hasDurableStorage; | ||
|
@@ -111,19 +113,9 @@ export namespace durableUtils { | |
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-member-access | ||
let packageReferences = result?.['Project']?.['ItemGroup']?.[0]?.PackageReference ?? []; | ||
packageReferences = (packageReferences instanceof Array) ? packageReferences : [packageReferences]; | ||
|
||
for (const packageRef of packageReferences) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
if (packageRef['$'] && packageRef['$']['Include']) { | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access | ||
if (packageRef['$']['Include'] === dotnetDfBasePackage) { | ||
resolve(true); | ||
return; | ||
} | ||
} | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access | ||
resolve(packageReferences.some(p => /Durable/i.test(p?.['$']?.['Include'] ?? ''))); | ||
} | ||
resolve(false); | ||
}); | ||
}); | ||
} | ||
|
@@ -151,7 +143,7 @@ export namespace durableUtils { | |
await installNodeDependencies(context); | ||
break; | ||
case ProjectLanguage.Python: | ||
await pythonUtils.addDependencyToRequirements(durableUtils.pythonDfPackage, context.projectPath); | ||
await pythonUtils.addDependencyToRequirements(pythonDfPackage, context.projectPath); | ||
await venvUtils.runPipInstallCommandIfPossible(context.projectPath); | ||
break; | ||
case ProjectLanguage.PowerShell: | ||
|
@@ -163,19 +155,28 @@ export namespace durableUtils { | |
|
||
async function installDotnetDependencies(context: IFunctionWizardContext): Promise<void> { | ||
const packageNames: string[] = []; | ||
const isDotnetIsolated: boolean = /Isolated/i.test(context.projectTemplateKey ?? ''); | ||
|
||
switch (context.newDurableStorageType) { | ||
case DurableBackend.Netherite: | ||
packageNames.push(durableUtils.dotnetDfNetheritePackage); | ||
isDotnetIsolated ? | ||
packageNames.push(dotnetIsolatedDfNetheritePackage) : | ||
packageNames.push(dotnetLtsDfNetheritePackage); | ||
break; | ||
case DurableBackend.SQL: | ||
packageNames.push(durableUtils.dotnetDfSqlPackage); | ||
isDotnetIsolated ? | ||
packageNames.push(dotnetIsolatedDfSqlPackage) : | ||
packageNames.push(dotnetLtsDfSqlPackage); | ||
break; | ||
case DurableBackend.Storage: | ||
default: | ||
} | ||
|
||
// Seems that the package arrives out-dated and needs to be updated | ||
packageNames.push(durableUtils.dotnetDfBasePackage); | ||
// Seems that the package arrives out-dated and needs to be updated to at least 2.9.1; | ||
// otherwise, error appears when running with sql backend | ||
if (!isDotnetIsolated) { | ||
packageNames.push(dotnetLtsDfBasePackage); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not 100% sure if this is the best way to handle this; let me know if anyone has opinions on if this should be handled differently. |
||
} | ||
|
||
const failedPackages: string[] = []; | ||
for (const packageName of packageNames) { | ||
|
@@ -194,10 +195,10 @@ export namespace durableUtils { | |
async function installNodeDependencies(context: IFunctionWizardContext): Promise<void> { | ||
try { | ||
const packageVersion = context.languageModel === 4 ? 'preview' : '2'; | ||
await cpUtils.executeCommand(ext.outputChannel, context.projectPath, 'npm', 'install', `${durableUtils.nodeDfPackage}@${packageVersion}`); | ||
await cpUtils.executeCommand(ext.outputChannel, context.projectPath, 'npm', 'install', `${nodeDfPackage}@${packageVersion}`); | ||
} catch (error) { | ||
const pError: IParsedError = parseError(error); | ||
const dfDepInstallFailed: string = localize('failedToAddDurableNodeDependency', 'Failed to add or install the "{0}" dependency. Please inspect and verify if it needs to be added manually.', durableUtils.nodeDfPackage); | ||
const dfDepInstallFailed: string = localize('failedToAddDurableNodeDependency', 'Failed to add or install the "{0}" dependency. Please inspect and verify if it needs to be added manually.', nodeDfPackage); | ||
ext.outputChannel.appendLog(pError.message); | ||
ext.outputChannel.appendLog(dfDepInstallFailed); | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unrelated to this PR, but there is a bug here if the package references are split into multiple item groups since we're only using the first item group. I can fix this in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh good catch! It should probably loop through the 'ItemGroup'[] and check for the 'PackageReference' instead