你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
New-AzureRmAutomationSourceControl
创建自动化源代码管理。
警告
截至 2024 年 2 月 29 日,AzureRM PowerShell 模块已正式弃用。 为了确保持续获得支持和更新,建议用户从 AzureRM 迁移到 Az PowerShell 模块。
尽管 AzureRM 模块仍可能正常运行,但它不再维护或受支持,但会根据用户的自由裁量权和风险继续使用任何继续使用模块。 有关过渡到 Az 模块的指导,请参阅我们的迁移资源。
语法
New-AzureRmAutomationSourceControl
-Name <String>
-RepoUrl <Uri>
-SourceType <String>
-AccessToken <SecureString>
-FolderPath <String>
[-Branch <String>]
[-Description <String>]
[-EnableAutoSync]
[-DoNotPublishRunbook]
[-ResourceGroupName] <String>
[-AutomationAccountName] <String>
[-DefaultProfile <IAzureContextContainer>]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
说明
New-AzureRmAutomationSourceControl cmdlet 创建一个配置,用于将Azure 自动化帐户与 VSTS TFVC、VSTS Git 或 GitHub 链接。
示例
示例 1
创建源代码管理配置,将Azure 自动化帐户与 VSTS TFVC 项目链接。 TFVC 项目没有分支,因此未指定 Branch 参数。
PS C:\> # VSTS Personal access token
PS C:\> $token = "vppmrabbs65axamofglyo66rjg6reddaa7xxgvaddd5555aaaaddxzbmma"
PS C:\> $accessToken = ConvertTo-SecureString -String $token -AsPlainText -Force
PS C:\> New-AzureRmAutomationSourceControl -ResourceGroupName "rg1" `
-AutomationAccountName "devAccount" `
-Name "VSTSNative" `
-RepoUrl "https://contoso.visualstudio.com/ContosoProduction/_versionControl" `
-SourceType "VsoTfvc" `
-FolderPath "/Runbooks" `
-AccessToken $accessToken
Name SourceType Branch FolderPath AutoSync PublishRunbook RepoUrl
---- ---------- ------ ---------- -------- -------------- -------
VSTSNative VsoTfvc /Runbooks True True https://contoso.visualstudio.com/ContosoProduc...
示例 2
创建源代码管理配置,将Azure 自动化帐户与 VSTS Git 项目链接。
PS C:\> # VSTS Personal access token
PS C:\> $token = "vppmrabbs65axamofglyo66rjg6reddaa7xxgvaddd5555aaaaddxzbmma"
PS C:\> $accessToken = ConvertTo-SecureString -String $token -AsPlainText -Force
PS C:\> New-AzureRmAutomationSourceControl -ResourceGroupName "rg1" `
-AutomationAccountName "devAccount" `
-Name "VSTSGit" `
-RepoUrl "https://contoso.visualstudio.com/_git/Finance" `
-SourceType "VsoGit" `
-Branch "Development" `
-FolderPath "/" `
-AccessToken $accessToken
Name SourceType Branch FolderPath AutoSync PublishRunbook RepoUrl
---- ---------- ------ ---------- -------- -------------- -------
VSTSGit VsoGit Development / True True https://contoso.visualstudio.com/_git/Finan...
示例 3
创建源代码管理配置,将Azure 自动化帐户与 GitHub 项目链接。
PS C:\> # GitHub access token
PS C:\> $token = "68b08011223aac8bdd3388913a44rrsaa84fdf"
PS C:\> $accessToken = ConvertTo-SecureString -String $token -AsPlainText -Force
PS C:\> New-AzureRmAutomationSourceControl -ResourceGroupName "rg1" `
-AutomationAccountName "devAccount" `
-Name "GitHub1" `
-RepoUrl "https://github.com/Contoso/TestSourceControl.git" `
-SourceType "GitHub" `
-Branch "master" `
-FolderPath "/Runbooks" `
-AccessToken $accessToken
Name SourceType Branch FolderPath AutoSync PublishRunbook RepoUrl
---- ---------- ------ ---------- -------- -------------- -------
GitHub1 GitHub master /Runbooks True True https://github.com/Contoso/TestSourceControl...
参数
-AccessToken
源代码管理访问令牌。
类型: | SecureString |
Position: | Named |
默认值: | None |
必需: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-AutomationAccountName
自动化帐户名称。
类型: | String |
Position: | 1 |
默认值: | None |
必需: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-Branch
源代码管理分支。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
提示你在运行 cmdlet 之前进行确认。
类型: | SwitchParameter |
Aliases: | cf |
Position: | Named |
默认值: | False |
必需: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DefaultProfile
用于与 Azure 通信的凭据、帐户、租户和订阅。
类型: | IAzureContextContainer |
Aliases: | AzureRmContext, AzureCredential |
Position: | Named |
默认值: | None |
必需: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Description
源代码管理说明。
类型: | String |
Position: | Named |
默认值: | None |
必需: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-DoNotPublishRunbook
源代码管理的 publishRunbook 属性。 如果设置了 DoNotPublishRunbook,这意味着用户 Runbook 将导入为“Draft”。
类型: | SwitchParameter |
Position: | Named |
默认值: | False |
必需: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-EnableAutoSync
源代码管理的 autoSync 属性。
类型: | SwitchParameter |
Position: | Named |
默认值: | False |
必需: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-FolderPath
源代码管理文件夹路径。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Name
源代码管理名称。
类型: | String |
Position: | Named |
默认值: | None |
必需: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-RepoUrl
源代码管理存储库 URL。
类型: | Uri |
Position: | Named |
默认值: | None |
必需: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-ResourceGroupName
资源组名称。
类型: | String |
Position: | 0 |
默认值: | None |
必需: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-SourceType
源代码管理类型。
类型: | String |
接受的值: | GitHub, VsoGit, VsoTfvc |
Position: | Named |
默认值: | None |
必需: | True |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
显示运行该 cmdlet 时会发生什么情况。 cmdlet 未运行。
类型: | SwitchParameter |
Aliases: | wi |
Position: | Named |
默认值: | False |
必需: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |