我的 Azure Service Fabric 应用程序有时需要比 MAX_PATH 更长的路径,尤其是考虑到工作目录的长度。因此,我想启用长文件路径(通过注册表的 LongPathsEnabled 值、组策略或其他机制,请参阅https://superuser.com/questions/1119883/windows-10-enable-ntfs-长路径策略选项缺失)。但我不知道该怎么做。
集群在 Azure VMSS 上运行,因此我可以远程访问各个实例并手动设置它,但这当然不能很好地扩展。
更新:
@4c74356b41 的回答让我大部分时间都在我需要的地方。我的 VMSS 已经安装了 customScript 扩展,所以我实际上必须修改它以包含 PS 命令,这是我的最终命令:
# Get the existing VMSS configuration
$vmss = Get-AzVmss -ResourceGroupName <resourceGroup> -Name <vmss>
# inspect $vmss to determine which extension is the customScript, in ours it's at index 3. Note the existing commandToExecute blob, you'll need to modify it to add the additional PS command
# modify the existing Settings.commandToExecute blob to add the reg set command
$vmss.VirtualMachineProfile.ExtensionProfile.Extensions[3].Settings.commandToExecute = 'powershell -ExecutionPolicy Unrestricted -File AzureQualysCloudAgentPowerShell_v2.ps1 && powershell -c "Set-ItemProperty -Path HKLM:\System\ControlSet001\Control\FileSystem -Name LongPathsEnabled -Value 1"'
# update the VMSS with the new config
Update-AzVmss -ResourceGroupName $vmss.ResourceGroupName -Name $vmss.Name -VirtualMachineScaleSet $vmss