gpt4 book ai didi

azure - Runbook 模块部署失败,因为它达到了终端预配状态 'Failed'

转载 作者:行者123 更新时间:2023-12-03 02:00:42 24 4
gpt4 key购买 nike

我想使用二头肌在 Azure 上使用 PowerShell 创建一些自动化 Runbook。为此,我需要下面列出的一些自定义模块。

var modules = [
'Microsoft.Graph.Authentication'
'Microsoft.Graph.Groups'
'Microsoft.Graph.Mail'
'Microsoft.Graph.Planner'
'Microsoft.Graph.Teams'
'Microsoft.Graph.Users'
'Microsoft.Graph.Users.Actions'
]

以下是我创建模块的方法:

resource automationResource 'Microsoft.Automation/automationAccounts@2022-08-08' = {
// Some other properties

resource moduleResources 'modules' = [for module in modules: {
name: module
properties: {
contentLink: {
uri: 'https://www.powershellgallery.com/api/v2/'
}
}
}]
}

当我将其部署到 Azure 时,所有模块都出现下一个错误:

{
"status": "Failed",
"error": {
"code": "ResourceDeploymentFailure",
"target": "/subscriptions/xxx/resourceGroups/xxx/providers/Microsoft.Automation/automationAccounts/xxx/modules/Microsoft.Graph.Teams",
"message": "The resource write operation failed to complete successfully, because it reached terminal provisioning state 'Failed'."
}
}

为什么模块不会添加到自动化帐户中?

最佳答案

这里有一些事情:

  1. 您需要包的完整 URL:名称 + 版本
  2. 如果包有一些依赖项,则需要先导入依赖项。

这里,所有包都依赖于 Microsoft.Graph.Authentication 包。

实现这一点的最简单方法是按顺序部署模块,但速度会很慢:

var modules = [
{
name: 'Microsoft.Graph.Authentication'
version: '2.0.0-preview8'
}
{
name: 'Microsoft.Graph.Groups'
version: '2.0.0-preview8'
}
{
name: 'Microsoft.Graph.Mail'
version: '2.0.0-preview8'
}
{
name: 'Microsoft.Graph.Planner'
version: '2.0.0-preview8'
}
{
name: 'Microsoft.Graph.Teams'
version: '2.0.0-preview8'
}
{
name: 'Microsoft.Graph.Users'
version: '2.0.0-preview8'
}
{
name: 'Microsoft.Graph.Users.Actions'
version: '2.0.0-preview8'
}
]

resource automationAccount 'Microsoft.Automation/automationAccounts@2022-08-08' existing = {
name: automationAccountName
}

@batchSize(1)
resource automationAccountModules 'Microsoft.Automation/automationAccounts/modules@2022-08-08' = [for module in modules: {
parent: automationAccount
name: module.name
properties: {
contentLink: {
uri: toLower('https://devopsgallerystorage.blob.core.windows.net:443/packages/${module.name}.${module.version}.nupkg')
}
}
}]

或者您可以在导入其他模块之前导入 Microsoft.Graph.Authentication:

var modules = [
{
name: 'Microsoft.Graph.Authentication'
version: '2.0.0-preview8'
}
{
name: 'Microsoft.Graph.Groups'
version: '2.0.0-preview8'
}
{
name: 'Microsoft.Graph.Mail'
version: '2.0.0-preview8'
}
{
name: 'Microsoft.Graph.Planner'
version: '2.0.0-preview8'
}
{
name: 'Microsoft.Graph.Teams'
version: '2.0.0-preview8'
}
{
name: 'Microsoft.Graph.Users'
version: '2.0.0-preview8'
}
{
name: 'Microsoft.Graph.Users.Actions'
version: '2.0.0-preview8'
}
]

resource automationAccount 'Microsoft.Automation/automationAccounts@2022-08-08' existing = {
name: automationAccountName
}

var authPackage = first(modules)
resource authModule 'Microsoft.Automation/automationAccounts/modules@2022-08-08' = {
parent: automationAccount
name: authPackage.name
properties: {
contentLink: {
uri: toLower('https://devopsgallerystorage.blob.core.windows.net:443/packages/${authPackage.name}.${authPackage.version}.nupkg')
}
}
}

var otherPackages = skip(modules, 1)
resource automationAccountModules 'Microsoft.Automation/automationAccounts/modules@2022-08-08' = [for module in otherPackages: {
dependsOn: [ authModule ]
parent: automationAccount
name: module.name
properties: {
contentLink: {
uri: toLower('https://devopsgallerystorage.blob.core.windows.net:443/packages/${module.name}.${module.version}.nupkg')
}
}
}]

关于azure - Runbook 模块部署失败,因为它达到了终端预配状态 'Failed',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76155998/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com