Skip to content

Commit 4869824

Browse files
markcowlisra-fel
andauthored
Custom providers (#12277)
* Initial commit for custom providers * Adding tests * Update help * Update New-AzCustomProvider.md * remove tools/ * docs * Update New-AzCustomProvider.md Co-authored-by: Yeming Liu <[email protected]>
1 parent 65f4593 commit 4869824

39 files changed

+2795
-0
lines changed

src/CustomProviders/.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
* text=auto

src/CustomProviders/.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
bin
2+
obj
3+
.vs
4+
generated
5+
internal
6+
exports
7+
custom/*.psm1
8+
test/*-TestResults.xml
9+
/*.ps1
10+
/*.ps1xml
11+
/*.psm1
12+
/*.snk
13+
/*.csproj
14+
/*.nuspec
15+
tools/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@{
2+
GUID = 'b98dded0-6e9a-4371-b2c6-d74464fb724b'
3+
RootModule = './Az.CustomProviders.psm1'
4+
ModuleVersion = '0.1.0'
5+
CompatiblePSEditions = 'Core', 'Desktop'
6+
Author = 'Microsoft Corporation'
7+
CompanyName = 'Microsoft Corporation'
8+
Copyright = 'Microsoft Corporation. All rights reserved.'
9+
Description = 'Microsoft Azure PowerShell: Custom Providers cmdlets'
10+
PowerShellVersion = '5.1'
11+
DotNetFrameworkVersion = '4.7.2'
12+
RequiredAssemblies = './bin/Az.CustomProviders.private.dll'
13+
FormatsToProcess = './Az.CustomProviders.format.ps1xml'
14+
FunctionsToExport = 'Get-AzCustomProvider', 'Get-AzCustomProviderAssociation', 'New-AzCustomProvider', 'New-AzCustomProviderAssociation', 'Remove-AzCustomProvider', 'Remove-AzCustomProviderAssociation', 'Update-AzCustomProvider', '*'
15+
AliasesToExport = '*'
16+
PrivateData = @{
17+
PSData = @{
18+
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'CustomProviders'
19+
LicenseUri = 'https://aka.ms/azps-license'
20+
ProjectUri = 'https://github.com/Azure/azure-powershell'
21+
ReleaseNotes = ''
22+
}
23+
}
24+
}
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 `Az.CustomProviders` 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 `Az.CustomProviders.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 `Az.CustomProviders` 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/Az.CustomProviders.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 `Az.CustomProviders.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundemental 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 `Az.CustomProviders`. 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.CustomProviders.Models.DescriptionAttribute`
35+
- Used in C# cmdlets to provide a high-level description of the cmdlet. This is propegated to reference documentation via [help comments](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts.
36+
- `Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.DoNotExportAttribute`
37+
- Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Az.CustomProviders`.
38+
- `Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.InternalExportAttribute`
39+
- Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.CustomProviders`. For more information, see [readme.md](..\internal/readme.md) in the `..\internal` folder.
40+
- `Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ProfileAttribute`
41+
- Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
Module Name: Az.CustomProviders
3+
Module Guid: b98dded0-6e9a-4371-b2c6-d74464fb724b
4+
Download Help Link: https://docs.microsoft.com/en-us/powershell/module/az.customproviders
5+
Help Version: 1.0.0.0
6+
Locale: en-US
7+
---
8+
9+
# Az.CustomProviders Module
10+
## Description
11+
Microsoft Azure PowerShell: Custom Providers cmdlets
12+
13+
## Az.CustomProviders Cmdlets
14+
### [Get-AzCustomProvider](Get-AzCustomProvider.md)
15+
Gets the custom resource provider manifest.
16+
17+
### [Get-AzCustomProviderAssociation](Get-AzCustomProviderAssociation.md)
18+
Get an association.
19+
20+
### [New-AzCustomProvider](New-AzCustomProvider.md)
21+
Creates or updates the custom resource provider.
22+
23+
### [New-AzCustomProviderAssociation](New-AzCustomProviderAssociation.md)
24+
Create or update an association.
25+
26+
### [Remove-AzCustomProvider](Remove-AzCustomProvider.md)
27+
Deletes the custom resource provider.
28+
29+
### [Remove-AzCustomProviderAssociation](Remove-AzCustomProviderAssociation.md)
30+
Delete an association.
31+
32+
### [Update-AzCustomProvider](Update-AzCustomProvider.md)
33+
Updates an existing custom resource provider.
34+
The only value that can be updated via PATCH currently is the tags.
35+
Lines changed: 182 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,182 @@
1+
---
2+
external help file:
3+
Module Name: Az.CustomProviders
4+
online version: https://docs.microsoft.com/en-us/powershell/module/az.customproviders/get-azcustomprovider
5+
schema: 2.0.0
6+
---
7+
8+
# Get-AzCustomProvider
9+
10+
## SYNOPSIS
11+
Gets the custom resource provider manifest.
12+
13+
## SYNTAX
14+
15+
### List1 (Default)
16+
```
17+
Get-AzCustomProvider [-SubscriptionId <String[]>] [-DefaultProfile <PSObject>] [<CommonParameters>]
18+
```
19+
20+
### Get
21+
```
22+
Get-AzCustomProvider -Name <String> -ResourceGroupName <String> [-SubscriptionId <String[]>]
23+
[-DefaultProfile <PSObject>] [<CommonParameters>]
24+
```
25+
26+
### GetViaIdentity
27+
```
28+
Get-AzCustomProvider -InputObject <ICustomProvidersIdentity> [-DefaultProfile <PSObject>] [<CommonParameters>]
29+
```
30+
31+
### List
32+
```
33+
Get-AzCustomProvider -ResourceGroupName <String> [-SubscriptionId <String[]>] [-DefaultProfile <PSObject>]
34+
[<CommonParameters>]
35+
```
36+
37+
## DESCRIPTION
38+
Gets the custom resource provider manifest.
39+
40+
## EXAMPLES
41+
42+
### Example 1: List all Custom Providers in a subscription
43+
```powershell
44+
PS C:\> Get-AzCustomProvider
45+
46+
Location Name Type
47+
-------- ---- ----
48+
West US 2 Namespace.Type Microsoft.CustomProviders/resourceproviders
49+
East US 2 Namespace2.Type Microsoft.CustomProviders/resourceproviders
50+
```
51+
52+
Lists all the custom providers in a subscription
53+
54+
### Example 2: Get a single custom provider
55+
```powershell
56+
PS C:\> Get-AzCustomProvider -ResourceGroupName myRg -Name Namespace.Type | Format-List
57+
58+
Action :
59+
Id : /subscriptions/xxxxx-yyyyy-xxxx-yyyy/resourceGroups/mc-cp01/providers/Microsoft.CustomProviders/resourceproviders/Namespace.Type
60+
Location : West US 2
61+
Name : Namespace.Type
62+
ProvisioningState : Succeeded
63+
ResourceType : {CustomRoute1, associations}
64+
Tag : Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ResourceTags
65+
Type : Microsoft.CustomProviders/resourceproviders
66+
Validation :
67+
68+
```
69+
70+
Gets details for a single custom provider.
71+
Use Format-List to show object details on the screen.
72+
73+
## PARAMETERS
74+
75+
### -DefaultProfile
76+
The credentials, account, tenant, and subscription used for communication with Azure.
77+
78+
```yaml
79+
Type: System.Management.Automation.PSObject
80+
Parameter Sets: (All)
81+
Aliases: AzureRMContext, AzureCredential
82+
83+
Required: False
84+
Position: Named
85+
Default value: None
86+
Accept pipeline input: False
87+
Accept wildcard characters: False
88+
```
89+
90+
### -InputObject
91+
Identity Parameter
92+
To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
93+
94+
```yaml
95+
Type: Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity
96+
Parameter Sets: GetViaIdentity
97+
Aliases:
98+
99+
Required: True
100+
Position: Named
101+
Default value: None
102+
Accept pipeline input: True (ByValue)
103+
Accept wildcard characters: False
104+
```
105+
106+
### -Name
107+
The name of the resource provider.
108+
109+
```yaml
110+
Type: System.String
111+
Parameter Sets: Get
112+
Aliases: ResourceProviderName
113+
114+
Required: True
115+
Position: Named
116+
Default value: None
117+
Accept pipeline input: False
118+
Accept wildcard characters: False
119+
```
120+
121+
### -ResourceGroupName
122+
The name of the resource group.
123+
124+
```yaml
125+
Type: System.String
126+
Parameter Sets: Get, List
127+
Aliases:
128+
129+
Required: True
130+
Position: Named
131+
Default value: None
132+
Accept pipeline input: False
133+
Accept wildcard characters: False
134+
```
135+
136+
### -SubscriptionId
137+
The Azure subscription ID.
138+
This is a GUID-formatted string (e.g.
139+
00000000-0000-0000-0000-000000000000)
140+
141+
```yaml
142+
Type: System.String[]
143+
Parameter Sets: Get, List, List1
144+
Aliases:
145+
146+
Required: False
147+
Position: Named
148+
Default value: (Get-AzContext).Subscription.Id
149+
Accept pipeline input: False
150+
Accept wildcard characters: False
151+
```
152+
153+
### CommonParameters
154+
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
155+
156+
## INPUTS
157+
158+
### Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.ICustomProvidersIdentity
159+
160+
## OUTPUTS
161+
162+
### Microsoft.Azure.PowerShell.Cmdlets.CustomProviders.Models.Api20180901Preview.ICustomRpManifest
163+
164+
## NOTES
165+
166+
ALIASES
167+
168+
COMPLEX PARAMETER PROPERTIES
169+
170+
To create the parameters described below, construct a hash table containing the appropriate properties. For information on hash tables, run Get-Help about_Hash_Tables.
171+
172+
173+
INPUTOBJECT <ICustomProvidersIdentity>: Identity Parameter
174+
- `[AssociationName <String>]`: The name of the association.
175+
- `[Id <String>]`: Resource identity path
176+
- `[ResourceGroupName <String>]`: The name of the resource group.
177+
- `[ResourceProviderName <String>]`: The name of the resource provider.
178+
- `[Scope <String>]`: The scope of the association.
179+
- `[SubscriptionId <String>]`: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000)
180+
181+
## RELATED LINKS
182+

0 commit comments

Comments
 (0)