Skip to content

Commit 0d17434

Browse files
committed
Moving RequiredModules metadata to readme.azurestack.md
1 parent bee89c9 commit 0d17434

File tree

21 files changed

+395
-60
lines changed

21 files changed

+395
-60
lines changed

src/Azs.Backup.Admin/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ internal
66
exports
77
tools
88
custom/*.psm1
9+
custom/autogen-model-cmdlets
910
test/*-TestResults.xml
1011
/*.ps1
1112
/*.ps1xml
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@{
2+
GUID = '2e202983-13f3-4bc9-a5fb-98911e8d1a12'
3+
RootModule = 'Azs.Backup.Admin.psm1'
4+
ModuleVersion = '1.0.2'
5+
CompatiblePSEditions = 'Core', 'Desktop'
6+
Author = 'Microsoft Corporation'
7+
CompanyName = 'Microsoft Corporation'
8+
Copyright = 'Microsoft Corporation. All rights reserved.'
9+
Description = 'Microsoft AzureStack PowerShell: Backup Admin cmdlets'
10+
PowerShellVersion = '5.1'
11+
DotNetFrameworkVersion = '4.7.2'
12+
RequiredModules = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = '2.2.8'}, @{ModuleName = 'Az.Resources'; ModuleVersion = '0.12.0'})
13+
RequiredAssemblies = './bin/Azs.Backup.Admin.private.dll'
14+
FormatsToProcess = './Azs.Backup.Admin.format.ps1xml'
15+
FunctionsToExport = 'Get-AzsBackup', 'Get-AzsBackupConfiguration', 'Invoke-AzsPruneBackupLocationExternalStore', 'Restore-AzsBackup', 'Set-AzsBackupConfiguration', 'Start-AzsBackup', '*'
16+
AliasesToExport = '*'
17+
PrivateData = @{
18+
PSData = @{
19+
Tags = 'AzureStack', 'ResourceManager', 'ARM', 'PSModule'
20+
LicenseUri = 'https://aka.ms/azps-license'
21+
ProjectUri = 'https://github.com/Azure/azurestack-powershell'
22+
ReleaseNotes = 'AzureStack Hub Admin module generated with https://github.com/Azure/autorest.powershell'
23+
}
24+
}
25+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Custom
2+
This directory contains custom implementation for non-generated cmdlets for the `Azs.Backup.Admin` module. Both scripts (`.ps1`) and C# files (`.cs`) can be implemented here. They will be used during the build process in `build-module.ps1`, and create cmdlets into the `..\exports` folder. The only generated file into this folder is the `Azs.Backup.Admin.custom.psm1`. This file should not be modified.
3+
4+
## Info
5+
- Modifiable: yes
6+
- Generated: partial
7+
- Committed: yes
8+
- Packaged: yes
9+
10+
## Details
11+
For `Azs.Backup.Admin` to use custom cmdlets, it does this two different ways. We **highly recommend** creating script cmdlets, as they are easier to write and allow access to the other exported cmdlets. C# cmdlets *cannot access exported cmdlets*.
12+
13+
For C# cmdlets, they are compiled with the rest of the generated low-level cmdlets into the `./bin/Azs.Backup.Admin.private.dll`. The names of the cmdlets (methods) and files must follow the `[cmdletName]_[variantName]` syntax used for generated cmdlets. The `variantName` is used as the `ParameterSetName`, so use something appropriate that doesn't clash with already created variant or parameter set names. You cannot use the `ParameterSetName` property in the `Parameter` attribute on C# cmdlets. Each cmdlet must be separated into variants using the same pattern as seen in the `generated/cmdlets` folder.
14+
15+
For script cmdlets, these are loaded via the `Azs.Backup.Admin.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundamental difference is the script cmdlets use the `ParameterSetName` attribute and C# cmdlets do not. To create a script cmdlet variant of a generated cmdlet, simply decorate all parameters in the script with the new `ParameterSetName` in the `Parameter` attribute. This will appropriately treat each parameter set as a separate variant when processed to be exported during the build.
16+
17+
## Purpose
18+
This allows the modules to have cmdlets that were not defined in the REST specification. It also allows combining logic using generated cmdlets. This is a level of customization beyond what can be done using the [readme configuration options](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md) that are currently available. These custom cmdlets are then referenced by the cmdlets created at build-time in the `..\exports` folder.
19+
20+
## Usage
21+
The easiest way currently to start developing custom cmdlets is to copy an existing cmdlet. For C# cmdlets, copy one from the `generated/cmdlets` folder. For script cmdlets, build the project using `build-module.ps1` and copy one of the scripts from the `..\exports` folder. After that, if you want to add new parameter sets, follow the guidelines in the `Details` section above. For implementing a new cmdlets, at minimum, please keep these parameters:
22+
- Break
23+
- DefaultProfile
24+
- HttpPipelineAppend
25+
- HttpPipelinePrepend
26+
- Proxy
27+
- ProxyCredential
28+
- ProxyUseDefaultCredentials
29+
30+
These provide functionality to our HTTP pipeline and other useful features. In script, you can forward these parameters using `$PSBoundParameters` to the other cmdlets you're calling within `Azs.Backup.Admin`. For C#, follow the usage seen in the `ProcessRecordAsync` method.
31+
32+
### Attributes
33+
For processing the cmdlets, we've created some additional attributes:
34+
- `Microsoft.Azure.PowerShell.Cmdlets.BackupAdmin.DescriptionAttribute`
35+
- Used in C# cmdlets to provide a high-level description of the cmdlet. This is propagated to reference documentation via [help comments](https://docs.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts.
36+
- `Microsoft.Azure.PowerShell.Cmdlets.BackupAdmin.DoNotExportAttribute`
37+
- Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Azs.Backup.Admin`.
38+
- `Microsoft.Azure.PowerShell.Cmdlets.BackupAdmin.InternalExportAttribute`
39+
- Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Azs.Backup.Admin`. For more information, see [README.md](..\internal/README.md) in the `..\internal` folder.
40+
- `Microsoft.Azure.PowerShell.Cmdlets.BackupAdmin.ProfileAttribute`
41+
- Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules.

src/Azs.Backup.Admin/how-to.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# How-To
2+
This document describes how to develop for `Azs.Backup.Admin`.
3+
4+
## Building `Azs.Backup.Admin`
5+
To build, run the `build-module.ps1` at the root of the module directory. This will generate the proxy script cmdlets that are the cmdlets being exported by this module. After the build completes, the proxy script cmdlets will be output to the `exports` folder. To read more about the proxy script cmdlets, look at the [README.md](exports/README.md) in the `exports` folder.
6+
7+
## Creating custom cmdlets
8+
To add cmdlets that were not generated by the REST specification, use the `custom` folder. This folder allows you to add handwritten `.ps1` and `.cs` files. Currently, we support using `.ps1` scripts as new cmdlets or as additional low-level variants (via `ParameterSet`), and `.cs` files as low-level (variants) cmdlets that the exported script cmdlets call. We do not support exporting any `.cs` (dll) cmdlets directly. To read more about custom cmdlets, look at the [README.md](custom/README.md) in the `custom` folder.
9+
10+
## Generating documentation
11+
To generate documentation, the process is now integrated into the `build-module.ps1` script. If you don't want to run this process as part of `build-module.ps1`, you can provide the `-NoDocs` switch. If you want to run documentation generation after the build process, you may still run the `generate-help.ps1` script. Overall, the process will look at the documentation comments in the generated and custom cmdlets and types, and create `.md` files into the `docs` folder. Additionally, this pulls in any examples from the `examples` folder and adds them to the generated help markdown documents. To read more about examples, look at the [README.md](examples/README.md) in the `examples` folder. To read more about documentation, look at the [README.md](docs/README.md) in the `docs` folder.
12+
13+
## Testing `Azs.Backup.Admin`
14+
To test the cmdlets, we use [Pester](https://github.com/pester/Pester). Tests scripts (`.ps1`) should be added to the `test` folder. To execute the Pester tests, run the `test-module.ps1` script. This will run all tests in `playback` mode within the `test` folder. To read more about testing cmdlets, look at the [README.md](examples/README.md) in the `examples` folder.
15+
16+
## Packing `Azs.Backup.Admin`
17+
To pack `Azs.Backup.Admin` for distribution, run the `pack-module.ps1` script. This will take the contents of multiple directories and certain root-folder files to create a `.nupkg`. The structure of the `.nupkg` is created so it can be loaded part of a [PSRepository](https://docs.microsoft.com/powershell/module/powershellget/register-psrepository). Additionally, this package is in a format for distribution to the [PSGallery](https://www.powershellgallery.com/). For signing an Azure module, please contact the [Azure PowerShell](https://github.com/Azure/azure-powershell) team.
18+
19+
## Module Script Details
20+
There are multiple scripts created for performing different actions for developing `Azs.Backup.Admin`.
21+
- `build-module.ps1`
22+
- Builds the module DLL (`./bin/Azs.Backup.Admin.private.dll`), creates the exported cmdlets and documentation, generates custom cmdlet test stubs and exported cmdlet example stubs, and updates `Azs.Backup.Admin.psd1` with Azure profile information.
23+
- **Parameters**: [`Switch` parameters]
24+
- `-Run`: After building, creates an isolated PowerShell session and loads `Azs.Backup.Admin`.
25+
- `-Test`: After building, runs the `Pester` tests defined in the `test` folder.
26+
- `-Docs`: After building, generates the Markdown documents for the modules into the `docs` folder.
27+
- `-Pack`: After building, packages the module into a `.nupkg`.
28+
- `-Code`: After building, opens a VSCode window with the module's directory and runs (see `-Run`) the module.
29+
- `-Release`: Builds the module in `Release` configuration (as opposed to `Debug` configuration).
30+
- `-NoDocs`: Supresses writing the documentation markdown files as part of the cmdlet exporting process.
31+
- `-Debugger`: Used when attaching the debugger in Visual Studio to the PowerShell session, and running the build process without recompiling the DLL. This suppresses running the script as an isolated process.
32+
- `run-module.ps1`
33+
- Creates an isolated PowerShell session and loads `Azs.Backup.Admin` into the session.
34+
- Same as `-Run` in `build-module.ps1`.
35+
- **Parameters**: [`Switch` parameters]
36+
- `-Code`: Opens a VSCode window with the module's directory.
37+
- Same as `-Code` in `build-module.ps1`.
38+
- `generate-help.ps1`
39+
- Generates the Markdown documents for the modules into the `docs` folder.
40+
- Same as `-Docs` in `build-module.ps1`.
41+
- `test-module.ps1`
42+
- Runs the `Pester` tests defined in the `test` folder.
43+
- Same as `-Test` in `build-module.ps1`.
44+
- `pack-module.ps1`
45+
- Packages the module into a `.nupkg` for distribution.
46+
- Same as `-Pack` in `build-module.ps1`.
47+
- `generate-help.ps1`
48+
- Generates the Markdown documents for the modules into the `docs` folder.
49+
- Same as `-Docs` in `build-module.ps1`.
50+
- This process is now integrated into `build-module.ps1` automatically. To disable, use `-NoDocs` when running `build-module.ps1`.
51+
- `export-surface.ps1`
52+
- Generates Markdown documents for both the cmdlet surface and the model (class) surface of the module.
53+
- These files are placed into the `resources` folder.
54+
- Used for investigating the surface of your module. These are *not* documentation for distribution.
55+
- `check-dependencies.ps1`
56+
- Used in `run-module.ps1` and `test-module.ps1` to verify dependent modules are available to run those tasks.
57+
- It will download local (within the module's directory structure) versions of those modules as needed.
58+
- This script *does not* need to be ran by-hand.

0 commit comments

Comments
 (0)