@@ -270,24 +270,15 @@ private async Task ApplyContext(HostAssignmentContext assignmentContext)
270270 }
271271 else if ( ! string . IsNullOrEmpty ( assignmentContext . AzureFilesConnectionString ) )
272272 {
273- ApplyAzureFilesContext ( assignmentContext . AzureFilesConnectionString , assignmentContext . AzureFilesContentShare , "/home" ) ;
273+ await MountCifs ( assignmentContext . AzureFilesConnectionString , assignmentContext . AzureFilesContentShare , "/home" ) ;
274274 }
275275 }
276276
277- private void ApplyAzureFilesContext ( string connectionString , string contentShare , string targetPath )
278- {
279- var sa = CloudStorageAccount . Parse ( connectionString ) ;
280- var key = Convert . ToBase64String ( sa . Credentials . ExportKey ( ) ) ;
281-
282- var mountCommand = $ "mount -t cifs //{ sa . FileEndpoint . Host } /{ contentShare } { targetPath } -o vers=3.0,username={ sa . Credentials . AccountName } ,password={ key } ,dir_mode=0777,file_mode=0777,serverino";
283- RunBashCommand ( $ "(mkdir -p { targetPath } || true) && ({ mountCommand } ) && (mkdir -p /home/site/wwwroot || true)", MetricEventNames . LinuxContainerSpecializationAzureFilesMount ) ;
284- }
285-
286277 private async Task ApplyBlobPackageContext ( RunFromPackageContext pkgContext , string targetPath )
287278 {
288279 // download zip and extract
289280 var filePath = await Download ( pkgContext ) ;
290- UnpackPackage ( filePath , targetPath , pkgContext ) ;
281+ await UnpackPackage ( filePath , targetPath , pkgContext ) ;
291282
292283 string bundlePath = Path . Combine ( targetPath , "worker-bundle" ) ;
293284 if ( Directory . Exists ( bundlePath ) )
@@ -368,7 +359,7 @@ private void AriaDownload(string directory, string fileName, Uri zipUri)
368359 _logger . LogInformation ( $ "{ fileInfo . Length } bytes downloaded") ;
369360 }
370361
371- private void UnpackPackage ( string filePath , string scriptPath , RunFromPackageContext pkgContext )
362+ private async Task UnpackPackage ( string filePath , string scriptPath , RunFromPackageContext pkgContext )
372363 {
373364 CodePackageType packageType ;
374365 using ( _metricsLogger . LatencyEvent ( MetricEventNames . LinuxContainerSpecializationGetPackageType ) )
@@ -385,15 +376,15 @@ private void UnpackPackage(string filePath, string scriptPath, RunFromPackageCon
385376 }
386377 else
387378 {
388- MountFsImage ( filePath , scriptPath ) ;
379+ await MountFuse ( "squashfs" , filePath , scriptPath ) ;
389380 }
390381 }
391382 else if ( packageType == CodePackageType . Zip )
392383 {
393384 // default to unzip for zip packages
394385 if ( _environment . IsMountEnabled ( ) )
395386 {
396- MountZipFile ( filePath , scriptPath ) ;
387+ await MountFuse ( "zip" , filePath , scriptPath ) ;
397388 }
398389 else
399390 {
@@ -451,40 +442,35 @@ private void UnzipPackage(string filePath, string scriptPath)
451442 }
452443
453444 private void UnsquashImage ( string filePath , string scriptPath )
454- => RunBashCommand ( $ "(mkdir -p ' { scriptPath } ' || true) && unsquashfs -f -d '{ scriptPath } ' '{ filePath } '", MetricEventNames . LinuxContainerSpecializationUnsquash ) ;
445+ => RunBashCommand ( $ "unsquashfs -f -d '{ scriptPath } ' '{ filePath } '", MetricEventNames . LinuxContainerSpecializationUnsquash ) ;
455446
456- private void MountFsImage ( string filePath , string scriptPath )
457- => RunFuseMount ( $ "squashfuse_ll -o nonempty '{ filePath } ' '{ scriptPath } '", scriptPath ) ;
447+ private async Task MountFuse ( string type , string filePath , string scriptPath )
448+ => await Mount ( new [ ]
449+ {
450+ new KeyValuePair < string , string > ( "operation" , type ) ,
451+ new KeyValuePair < string , string > ( "filePath" , filePath ) ,
452+ new KeyValuePair < string , string > ( "targetPath" , scriptPath ) ,
453+ } ) ;
458454
459- private void MountZipFile ( string filePath , string scriptPath )
460- => RunFuseMount ( $ "fuse-zip -o nonempty -r '{ filePath } ' '{ scriptPath } '", scriptPath ) ;
455+ private async Task MountCifs ( string connectionString , string contentShare , string targetPath )
456+ {
457+ var sa = CloudStorageAccount . Parse ( connectionString ) ;
458+ var key = Convert . ToBase64String ( sa . Credentials . ExportKey ( ) ) ;
459+ await Mount ( new [ ]
460+ {
461+ new KeyValuePair < string , string > ( "operation" , "cifs" ) ,
462+ new KeyValuePair < string , string > ( "host" , sa . FileEndpoint . Host ) ,
463+ new KeyValuePair < string , string > ( "accountName" , sa . Credentials . AccountName ) ,
464+ new KeyValuePair < string , string > ( "accountKey" , key ) ,
465+ new KeyValuePair < string , string > ( "contentShare" , contentShare ) ,
466+ new KeyValuePair < string , string > ( "targetPath" , targetPath ) ,
467+ } ) ;
468+ }
461469
462- private void RunFuseMount ( string mountCommand , string targetPath )
470+ private async Task Mount ( IEnumerable < KeyValuePair < string , string > > formData )
463471 {
464- using ( _metricsLogger . LatencyEvent ( MetricEventNames . LinuxContainerSpecializationFuseMount ) )
465- {
466- var bashCommand = $ "(mknod /dev/fuse c 10 229 || true) && (mkdir -p '{ targetPath } ' || true) && ({ mountCommand } )";
467- var process = new Process
468- {
469- StartInfo = new ProcessStartInfo
470- {
471- FileName = "bash" ,
472- Arguments = $ "-c \" { bashCommand } \" ",
473- RedirectStandardOutput = true ,
474- RedirectStandardError = true ,
475- UseShellExecute = false ,
476- CreateNoWindow = true
477- }
478- } ;
479- _logger . LogInformation ( $ "Running: { process . StartInfo . FileName } { process . StartInfo . Arguments } ") ;
480- process . Start ( ) ;
481- var output = process . StandardOutput . ReadToEnd ( ) ;
482- var error = process . StandardError . ReadToEnd ( ) ;
483- process . WaitForExit ( ) ;
484- _logger . LogInformation ( $ "Output: { output } ") ;
485- _logger . LogInformation ( $ "error: { output } ") ;
486- _logger . LogInformation ( $ "exitCode: { process . ExitCode } ") ;
487- }
472+ var res = await _client . PostAsync ( _environment . GetEnvironmentVariable ( EnvironmentSettingNames . MeshInitURI ) , new FormUrlEncodedContent ( formData ) ) ;
473+ _logger . LogInformation ( "Response {res} from init" , res ) ;
488474 }
489475
490476 private ( string , string , int ) RunBashCommand ( string command , string metricName )
0 commit comments