簡體   English   中英

在 Azure Service Fabric VMSS 群集上啟用長文件路徑

[英]Enabling long file paths on Azure Service Fabric VMSS cluster

我的 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

我建議使用腳本擴展和一個簡單的 powershell 腳本來設置這個值。 這將自動應用於所有實例(包括擴展時)。

{
    "apiVersion": "2018-06-01",
    "type": "Microsoft.Compute/virtualMachineScaleSet/extensions",
    "name": "config-app",
    "location": "[resourceGroup().location]",
    "properties": {
        "publisher": "Microsoft.Compute",
        "type": "CustomScriptExtension",
        "typeHandlerVersion": "1.9",
        "autoUpgradeMinorVersion": true,
        "settings": {
            "fileUris": []
        },
        "protectedSettings": {
            "commandToExecute": "powershell -c 'Set-Item HKLM:\System\CurrentControlSet\Policies\LongPathsEnabled -Value 1'"
        }
    }
}

命令本身可能有點不對,但是您可以在本地進行試驗並得到正確的結果,然后將其放入腳本擴展中

https://docs.microsoft.com/en-us/azure/virtual-machines/extensions/custom-script-windows

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM