Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/TrafficManager/TrafficManager.Autorest/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
16 changes: 16 additions & 0 deletions src/TrafficManager/TrafficManager.Autorest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
bin
obj
.vs
generated
internal
exports
tools
test/*-TestResults.xml
license.txt
/*.ps1
/*.psd1
/*.ps1xml
/*.psm1
/*.snk
/*.csproj
/*.nuspec
33 changes: 33 additions & 0 deletions src/TrafficManager/TrafficManager.Autorest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<!-- region Generated -->
# TrafficManager
This directory contains the PowerShell module for the TrafficManager service.

---
## Info
- Modifiable: yes
- Generated: all
- Committed: yes
- Packaged: yes

---
## Detail
This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension.

## Development
For information on how to develop for `TrafficManager`, see [how-to.md](how-to.md).
<!-- endregion -->

# AutoRest Configuration

> see https://aka.ms/autorest

```yaml
powershell: true
input-file:
- https://github.com/Azure/azure-rest-api-specs/blob/main/specification/trafficmanager/resource-manager/Microsoft.Network/TrafficManager/preview/2024-04-01-preview/trafficmanager.json
output-folder: ./
namespace: Az.TrafficManager
module-name: Az.TrafficManager
subject-prefix: 'TrafficManager'
prefix: Az
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,181 @@
{
"resourceType": "trafficmanagerprofiles",
"apiVersion": "2024-04-01-preview",
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/trafficmanager"
},
"commands": [
{
"name": "Get-AzTrafficManagerEndpoint",
"description": "Gets a Traffic Manager endpoint.",
"path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}",
"help": {
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/trafficmanager/get-aztrafficmanagerendpoint"
},
"parameterSets": [
{
"parameters": [
"-EndpointName <String>",
"-EndpointType <String>",
"-ProfileName <String>",
"-ResourceGroupName <String>",
"[-SubscriptionId <String>]"
]
}
]
},
"examples": [
{
"description": "Gets a Traffic Manager endpoint.",
"parameters": [
{
"name": "-EndpointName",
"value": "[Path.endpointName]"
},
{
"name": "-EndpointType",
"value": "[Path.endpointType]"
},
{
"name": "-ProfileName",
"value": "[Path.profileName]"
},
{
"name": "-ResourceGroupName",
"value": "[Path.resourceGroupName]"
},
{
"name": "-SubscriptionId",
"value": "[Path.subscriptionId]"
}
]
}
]
},
{
"name": "Get-AzTrafficManagerProfile",
"description": "Gets a Traffic Manager profile.",
"path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}",
"help": {
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/trafficmanager/get-aztrafficmanagerprofile"
},
"parameterSets": [
{
"parameters": [
"-ProfileName <String>",
"-ResourceGroupName <String>",
"[-SubscriptionId <String>]"
]
}
]
},
"examples": [
{
"description": "Gets a Traffic Manager profile.",
"parameters": [
{
"name": "-ProfileName",
"value": "[Path.profileName]"
},
{
"name": "-ResourceGroupName",
"value": "[Path.resourceGroupName]"
},
{
"name": "-SubscriptionId",
"value": "[Path.subscriptionId]"
}
]
}
]
},
{
"name": "Remove-AzTrafficManagerEndpoint",
"description": "Deletes a Traffic Manager endpoint.",
"path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}/{endpointType}/{endpointName}",
"help": {
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/trafficmanager/remove-aztrafficmanagerendpoint"
},
"parameterSets": [
{
"parameters": [
"-EndpointName <String>",
"-EndpointType <String>",
"-ProfileName <String>",
"-ResourceGroupName <String>",
"[-SubscriptionId <String>]"
]
}
]
},
"examples": [
{
"description": "Deletes a Traffic Manager endpoint.",
"parameters": [
{
"name": "-EndpointName",
"value": "[Path.endpointName]"
},
{
"name": "-EndpointType",
"value": "[Path.endpointType]"
},
{
"name": "-ProfileName",
"value": "[Path.profileName]"
},
{
"name": "-ResourceGroupName",
"value": "[Path.resourceGroupName]"
},
{
"name": "-SubscriptionId",
"value": "[Path.subscriptionId]"
}
]
}
]
},
{
"name": "Remove-AzTrafficManagerProfile",
"description": "Deletes a Traffic Manager profile.",
"path": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Network/trafficmanagerprofiles/{profileName}",
"help": {
"learnMore": {
"url": "https://learn.microsoft.com/powershell/module/trafficmanager/remove-aztrafficmanagerprofile"
},
"parameterSets": [
{
"parameters": [
"-ProfileName <String>",
"-ResourceGroupName <String>",
"[-SubscriptionId <String>]"
]
}
]
},
"examples": [
{
"description": "Deletes a Traffic Manager profile.",
"parameters": [
{
"name": "-ProfileName",
"value": "[Path.profileName]"
},
{
"name": "-ResourceGroupName",
"value": "[Path.resourceGroupName]"
},
{
"name": "-SubscriptionId",
"value": "[Path.subscriptionId]"
}
]
}
]
}
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
<#
.Synopsis
Adds an endpoint to a local Traffic Manager profile object.
.Description
The Add-AzTrafficManagerEndpointConfig cmdlet adds an endpoint to a local Azure Traffic Manager profile object.
This cmdlet modifies the object in memory only. To update the profile in Azure, use Set-AzTrafficManagerProfile.
.Example
$profile = Get-AzTrafficManagerProfile -Name MyProfile -ResourceGroupName MyRG
Add-AzTrafficManagerEndpointConfig -TrafficManagerProfile $profile -EndpointName MyEndpoint -Type AzureEndpoints -TargetResourceId $webAppId -EndpointStatus Enabled
Set-AzTrafficManagerProfile -TrafficManagerProfile $profile

.Inputs
Az.TrafficManager.Models.IProfile
.Outputs
Az.TrafficManager.Models.IProfile
#>
function Add-AzTrafficManagerEndpointConfig {
[OutputType([Az.TrafficManager.Models.IProfile])]
[CmdletBinding()]
param(
[Parameter(Mandatory, HelpMessage='The name of the endpoint to add.')]
[ValidateNotNullOrEmpty()]
[string]
${EndpointName},

[Parameter(Mandatory, ValueFromPipeline, HelpMessage='The Traffic Manager profile object to add the endpoint to.')]
[ValidateNotNullOrEmpty()]
[Az.TrafficManager.Models.IProfile]
${TrafficManagerProfile},

[Parameter(Mandatory, HelpMessage='The type of the endpoint (AzureEndpoints, ExternalEndpoints, or NestedEndpoints).')]
[ValidateSet('AzureEndpoints', 'ExternalEndpoints', 'NestedEndpoints', IgnoreCase=$true)]
[ValidateNotNullOrEmpty()]
[string]
${Type},

[Parameter(HelpMessage='The Azure resource ID of the endpoint target.')]
[string]
${TargetResourceId},

[Parameter(HelpMessage='The target FQDN of the endpoint.')]
[string]
${Target},

[Parameter(Mandatory, HelpMessage='The status of the endpoint (Enabled or Disabled).')]
[ValidateSet('Enabled', 'Disabled', IgnoreCase=$false)]
[ValidateNotNullOrEmpty()]
[string]
${EndpointStatus},
Comment on lines +45 to +49

[Parameter(HelpMessage='The weight of the endpoint for weighted routing.')]
[System.Nullable[System.Int64]]
${Weight},

[Parameter(HelpMessage='The priority of the endpoint for priority routing.')]
[System.Nullable[System.Int64]]
${Priority},

[Parameter(HelpMessage='The endpoint location for performance routing.')]
[string]
${EndpointLocation},

[Parameter(HelpMessage='If Always Serve is enabled, probing for endpoint health will be disabled.')]
[ValidateSet('Enabled', 'Disabled', IgnoreCase=$false)]
[string]
${AlwaysServe},
Comment on lines +63 to +66

[Parameter(HelpMessage='The minimum number of endpoints that must be available in the child profile. Only applicable to NestedEndpoints.')]
[System.Nullable[System.Int64]]
${MinChildEndpoints},

[Parameter(HelpMessage='The minimum number of IPv4 endpoints that must be available in the child profile. Only applicable to NestedEndpoints.')]
[System.Nullable[System.Int64]]
${MinChildEndpointsIPv4},

[Parameter(HelpMessage='The minimum number of IPv6 endpoints that must be available in the child profile. Only applicable to NestedEndpoints.')]
[System.Nullable[System.Int64]]
${MinChildEndpointsIPv6},

[Parameter(HelpMessage='The list of regions mapped to this endpoint for Geographic routing.')]
[string[]]
${GeoMapping},

[Parameter(HelpMessage='The list of subnets mapped to this endpoint for Subnet routing.')]
[Az.TrafficManager.Models.IEndpointPropertiesSubnetsItem[]]
${SubnetMapping},

[Parameter(HelpMessage='List of custom header name and value pairs for probe requests.')]
[Az.TrafficManager.Models.IEndpointPropertiesCustomHeadersItem[]]
${CustomHeader}
)

process {
# Check for duplicate endpoint name
if ($TrafficManagerProfile.Endpoints) {
$existing = $TrafficManagerProfile.Endpoints | Where-Object { $_.Name -eq $EndpointName }
if ($existing) {
throw "An endpoint with name '$EndpointName' already exists in the profile."
}
} else {
$TrafficManagerProfile.Endpoints = [System.Collections.Generic.List[Az.TrafficManager.Models.IEndpoint]]::new()
}

# Build the endpoint object
$endpoint = @{
Name = $EndpointName
Type = "Microsoft.Network/trafficManagerProfiles/$Type"
EndpointStatus = $EndpointStatus
}

if ($PSBoundParameters.ContainsKey('TargetResourceId')) { $endpoint['TargetResourceId'] = $TargetResourceId }
if ($PSBoundParameters.ContainsKey('Target')) { $endpoint['Target'] = $Target }
if ($PSBoundParameters.ContainsKey('Weight')) { $endpoint['Weight'] = $Weight }
if ($PSBoundParameters.ContainsKey('Priority')) { $endpoint['Priority'] = $Priority }
if ($PSBoundParameters.ContainsKey('EndpointLocation')) { $endpoint['EndpointLocation'] = $EndpointLocation }
if ($PSBoundParameters.ContainsKey('AlwaysServe')) { $endpoint['AlwaysServe'] = $AlwaysServe }
if ($PSBoundParameters.ContainsKey('MinChildEndpoints')) { $endpoint['MinChildEndpoints'] = $MinChildEndpoints }
if ($PSBoundParameters.ContainsKey('MinChildEndpointsIPv4')) { $endpoint['MinChildEndpointsIPv4'] = $MinChildEndpointsIPv4 }
if ($PSBoundParameters.ContainsKey('MinChildEndpointsIPv6')) { $endpoint['MinChildEndpointsIPv6'] = $MinChildEndpointsIPv6 }
if ($PSBoundParameters.ContainsKey('GeoMapping')) { $endpoint['GeoMapping'] = [System.Collections.Generic.List[string]]$GeoMapping }
if ($PSBoundParameters.ContainsKey('SubnetMapping')) { $endpoint['Subnets'] = [System.Collections.Generic.List[Az.TrafficManager.Models.IEndpointPropertiesSubnetsItem]]$SubnetMapping }
if ($PSBoundParameters.ContainsKey('CustomHeader')) { $endpoint['CustomHeaders'] = [System.Collections.Generic.List[Az.TrafficManager.Models.IEndpointPropertiesCustomHeadersItem]]$CustomHeader }

# Add to profile's endpoint list
$TrafficManagerProfile.Endpoints.Add([Az.TrafficManager.Models.Endpoint]$endpoint)

Write-Output $TrafficManagerProfile
}
}
Loading
Loading