Azure / Azure/azure-powershell
[Feature]: Include module path in Publish-AzVMDscConfiguration DSC archive
- Dominant language
- C#
- Stars
- 4.8k
- Forks
- 4.3k
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 51
Description
### Description of the new feature
When running the `Publish-AzVMDscConfiguration` cmdlet without the `-SkipDependencyDetection` parameter, the cmdlet creates an archive that contains the DSC configuration and any resource modules that it imports.
When the archive is created, the required modules are copied from their module path to a temporary directory. Although the source module includes the module's version in its path, the copy of the module in the temporary directory does not.
Later, when the Azure VM DSC extension attempts to bootstrap the required modules from the archive, it extracts them to `$env:ProgramFiles\WindowsPowerShell\Modules`. Because the module's path in the archive does not include a module version, the DSC extension completely replaces the required module's directory and subdirectories with the contents of the required module's directory from the DSC configuration archive. Any versions of the module that may already exist in the destination directory will be completely removed.
For example, if you import PackageManagement v1.0.0.1 (a built-in cmdlet included with Windows PowerShell 5.1) in your DSC configuration and then create the configuration archive with `Publish-AzVMDscConfiguration`, it will remove the pre-installed PackageManagement v1.0.0.1 directory (`$env:ProgramFiles\WindowsPowerShell\Modules\PackageManagement\1.0.0.1`) and place the contents of the version included in the archive at `$env:ProgramFiles\WindowsPowerShell\Modules\PackageManagement` (note: no version).
### Proposed implementation details (optional)
Update the logic of the `Publish-AzVMDscConfiguration` cmdlet to copy the local module to a temporary directory **that includes the module's version** when the `-SkipDependencyDetection` parameter is not passed.
Contributor guide
Assessment
This issue has not been assessed yet.