@@ -10,7 +10,7 @@ import * as xml2js from "xml2js";
10
10
import { type IFunctionWizardContext } from "../commands/createFunction/IFunctionWizardContext" ;
11
11
import { ConnectionKey , DurableBackend , ProjectLanguage , hostFileName , requirementsFileName , type DurableBackendValues } from "../constants" ;
12
12
import { ext } from "../extensionVariables" ;
13
- import { type IHostJsonV2 , type INetheriteTaskJson , type ISqlTaskJson , type IStorageTaskJson } from "../funcConfig/host" ;
13
+ import { type IDTSTaskJson , type IHostJsonV2 , type INetheriteTaskJson , type ISqlTaskJson , type IStorageTaskJson } from "../funcConfig/host" ;
14
14
import { localize } from "../localize" ;
15
15
import { cpUtils } from "./cpUtils" ;
16
16
import { dotnetUtils } from "./dotnetUtils" ;
@@ -24,6 +24,8 @@ export namespace durableUtils {
24
24
export const dotnetIsolatedDfSqlPackage : string = 'Microsoft.Azure.Functions.Worker.Extensions.DurableTask.SqlServer' ;
25
25
export const dotnetInProcDfNetheritePackage : string = 'Microsoft.Azure.DurableTask.Netherite.AzureFunctions' ;
26
26
export const dotnetIsolatedDfNetheritePackage : string = 'Microsoft.Azure.Functions.Worker.Extensions.DurableTask.Netherite' ;
27
+ export const dotnetInProcDTSPackage : string = 'Microsoft.Azure.WebJobs.Extensions.DurableTask.AzureManaged' ;
28
+ export const dotnetIsolatedDTSPackage : string = 'Microsoft.Azure.Functions.Worker.Extensions.DurableTask.AzureManaged' ;
27
29
export const dotnetInProcDfBasePackage : string = 'Microsoft.Azure.WebJobs.Extensions.DurableTask' ;
28
30
export const nodeDfPackage : string = 'durable-functions' ;
29
31
export const pythonDfPackage : string = 'azure-functions-durable' ;
@@ -62,6 +64,8 @@ export namespace durableUtils {
62
64
switch ( hostStorageType ) {
63
65
case DurableBackend . Netherite :
64
66
return DurableBackend . Netherite ;
67
+ case DurableBackend . DTS :
68
+ return DurableBackend . DTS ;
65
69
case DurableBackend . SQL :
66
70
return DurableBackend . SQL ;
67
71
case DurableBackend . Storage :
@@ -150,39 +154,46 @@ export namespace durableUtils {
150
154
}
151
155
152
156
async function installDotnetDependencies ( context : IFunctionWizardContext ) : Promise < void > {
153
- const packageNames : string [ ] = [ ] ;
157
+ const packages : { name : string ; prerelease ?: boolean } [ ] = [ ] ;
154
158
const isDotnetIsolated : boolean = / I s o l a t e d / i. test ( context . functionTemplate ?. id ?? '' ) ;
155
159
156
160
switch ( context . newDurableStorageType ) {
157
161
case DurableBackend . Netherite :
158
162
isDotnetIsolated ?
159
- packageNames . push ( dotnetIsolatedDfNetheritePackage ) :
160
- packageNames . push ( dotnetInProcDfNetheritePackage ) ;
163
+ packages . push ( { name : dotnetIsolatedDfNetheritePackage } ) :
164
+ packages . push ( { name : dotnetInProcDfNetheritePackage } ) ;
165
+ break ;
166
+ case DurableBackend . DTS :
167
+ // Todo: Remove prerelease flag once this functionality is out of preview
168
+ isDotnetIsolated ?
169
+ packages . push ( { name : dotnetIsolatedDTSPackage , prerelease : true } ) :
170
+ packages . push ( { name : dotnetInProcDTSPackage , prerelease : true } ) ;
161
171
break ;
162
172
case DurableBackend . SQL :
163
173
isDotnetIsolated ?
164
- packageNames . push ( dotnetIsolatedDfSqlPackage ) :
165
- packageNames . push ( dotnetInProcDfSqlPackage ) ;
174
+ packages . push ( { name : dotnetIsolatedDfSqlPackage } ) :
175
+ packages . push ( { name : dotnetInProcDfSqlPackage } ) ;
166
176
break ;
167
177
case DurableBackend . Storage :
168
178
default :
169
179
}
170
180
171
- /*
172
- * https://github.com/microsoft/vscode-azurefunctions/issues/3599
173
- * Seems that the package arrives out-dated and needs to be updated to at least 2.9.1;
174
- * otherwise, error appears when running with sql backend
175
- */
181
+ // Although the templates should incorporate this package already, it is often included with an out-dated version
182
+ // which can lead to errors on first run. To improve this experience for our users, ensure that the latest version is used.
176
183
if ( ! isDotnetIsolated ) {
177
- packageNames . push ( dotnetInProcDfBasePackage ) ;
184
+ packages . push ( { name : dotnetInProcDfBasePackage } ) ;
178
185
}
179
186
180
187
const failedPackages : string [ ] = [ ] ;
181
- for ( const packageName of packageNames ) {
188
+ for ( const p of packages ) {
182
189
try {
183
- await cpUtils . executeCommand ( ext . outputChannel , context . projectPath , 'dotnet' , 'add' , 'package' , packageName ) ;
190
+ const packageArgs : string [ ] = [ p . name ] ;
191
+ if ( p . prerelease ) {
192
+ packageArgs . push ( '--prerelease' ) ;
193
+ }
194
+ await cpUtils . executeCommand ( ext . outputChannel , context . projectPath , 'dotnet' , 'add' , 'package' , ...packageArgs ) ;
184
195
} catch {
185
- failedPackages . push ( packageName ) ;
196
+ failedPackages . push ( p . name ) ;
186
197
}
187
198
}
188
199
@@ -215,9 +226,9 @@ export namespace durableUtils {
215
226
} ;
216
227
}
217
228
218
- export function getDefaultNetheriteTaskConfig ( hubName ? : string ) : INetheriteTaskJson {
229
+ export function getDefaultNetheriteTaskConfig ( hubName : string = '' ) : INetheriteTaskJson {
219
230
return {
220
- hubName : hubName || '' ,
231
+ hubName,
221
232
useGracefulShutdown : true ,
222
233
storageProvider : {
223
234
type : DurableBackend . Netherite ,
@@ -227,6 +238,16 @@ export namespace durableUtils {
227
238
} ;
228
239
}
229
240
241
+ export function getDefaultDTSTaskConfig ( ) : IDTSTaskJson {
242
+ return {
243
+ hubName : '%TASKHUB_NAME%' ,
244
+ storageProvider : {
245
+ type : DurableBackend . DTS ,
246
+ connectionStringName : ConnectionKey . DTS ,
247
+ }
248
+ } ;
249
+ }
250
+
230
251
export function getDefaultSqlTaskConfig ( ) : ISqlTaskJson {
231
252
return {
232
253
storageProvider : {
0 commit comments