Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Need support of PowerShell7 for azurerm_automation_runbook and azurerm_automation_module #14089

Closed
alex-3sr opened this issue Nov 8, 2021 · 16 comments · Fixed by #24230
Closed

Comments

@alex-3sr
Copy link

alex-3sr commented Nov 8, 2021

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Description

Hi,

The feature is still in preview, but it's look like nice to get support of PowerShell 7.1 runtime for runbook.
As a possible workaround for now, I have this process ->

  1. Deploy new runbook as usual
  2. Delete runbook from GUI and recreate from GUI again with same content
  3. Add lifecyle ignore_change on runbook_type
  4. Redeploy for add additionnals settings (schedule, ...) and permit to still update content

but this workaround have many limitation, if runbook need to be destroy/recreate that will revert to ps5, and unable to manage PowerShell module with v7 at this time too.

Thanks, have a nice day
Regards
Alex

New or Affected Resource(s)

  • azurerm_automation_runbook
  • azurerm_automation_module

Potential Terraform Configuration

resource "azurerm_automation_runbook" "runbook_test" {
  name                    = "Test"
  location                = azurerm_resource_group.rgproject.location
  resource_group_name     = azurerm_resource_group.rgproject.name
  automation_account_name = azurerm_automation_account.automationaccount.name
  log_verbose             = "false"
  log_progress            = "true"
  runbook_type            = "PowerShell7"
  content                 = data.local_file.runbook_content.content
}
resource "azurerm_automation_module" "module_automation" {
  name                    = "Az.Accounts"
  resource_group_name     = azurerm_resource_group.rgproject.name
  automation_account_name = azurerm_automation_account.automationaccount.name
  runtime_version = "PowerShell7"

  module_link {
    uri = "https://psg-prod-eastus.azureedge.net/packages/az.accounts.2.2.5.nupkg"
  }
}

References

  • #0000
@DionKllokoqi
Copy link

I'm also facing this issue currently. Powershell 7.1 can also run az commands, which 5.1 cannot.

@aristosvo aristosvo added enhancement sdk/not-yet-supported Support for this does not exist in the upstream SDK at this time service/automation labels Nov 11, 2021
@aristosvo
Copy link
Collaborator

aristosvo commented Nov 11, 2021

Hi all! All up to now published APIs don't have that option unfortunately, thus impossible to enable this at the moment unfortunately.

This enum is lacking a specific version 7.1 option

@alxgda
Copy link

alxgda commented Jan 17, 2022

Still waiting for this! Such a turn off!

@lyceus
Copy link

lyceus commented Mar 14, 2022

This enum is lacking a specific version 7.1 option

The Azure Portal uses the value "PowerShell7" for this parameter to create a PS7.1 (preview) runbook. API version used by that call is "2017-05-15-preview" if that makes a difference. I'm afraid I don't have the expertise to test if this can work in the codebase, but hopefully that info can help.

@eltimmo
Copy link
Contributor

eltimmo commented Nov 9, 2022

Hi, I had same issue. It's not supported in PowerShell or pretty much anything. As a work around you can get this to work using azapi like below. If you need to upload a script you'll need to create some storage with no IP restrictions, upload your PS to it, generate a SAS and use publishContentLink to upload this.

resource "azapi_resource" "automation" {

  type      = "Microsoft.Automation/automationAccounts/runbooks@2022-08-08"
  name      = "runbook"
  parent_id = azurerm_automation_account.{?}.id
  location  = "westeurope"
 
  body = jsonencode({
    properties = {
      runbookType        = "PowerShell7"
      logVerbose         = false
      logProgress        = false
      logActivityTrace   = 0
      publishContentLink = {
        uri = "${azurerm_storage_blob.{?}}.url}${data.azurerm_storage_account_blob_container_sas.{?}.sas}"
      }
    }
  })
  
  response_export_values = ["*"]

  depends_on = [
    data.azurerm_storage_account_blob_container_sas.{?}
  ]

}

@jcarlosbeta
Copy link

Is there any update about this issue?
runbook_type = "PowerShell7" is still not available in latest version 3.71.0 https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/automation_runbook.html#runbook_type
Any news about its support now that there is even version 7.2 (preview) ???

@mrchops1024
Copy link

Here's the azapi_rezource I used to import a PowerShell 7.1 module:

resource "azapi_resource" "powershell7_module" {
  type      = "Microsoft.Automation/automationAccounts/powershell7Modules@2019-06-01"
  name      = "<module name>"
  parent_id = "<automation account id>"
  location  = "<location>"
  schema_validation_enabled = false # Required because this resource won't validate

  body = jsonencode({
    properties = {
      contentLink = {
        uri = "<url to module version>"
      }
    }
  })

  response_export_values = ["*"]

  # Not sure if this dependency is needed
  depends_on = [
    azurerm_automation_account
  ]
}

@AtosAleti
Copy link

any update?

@rdeberry-sms
Copy link

bump

1 similar comment
@razgrim
Copy link

razgrim commented Oct 18, 2023

bump

@flipflop97
Copy link

flipflop97 commented Nov 1, 2023

For 7.2, the version can be passed as argument runtime, for 7.1, the runbookType is changed.

These requests were generated using the Azure Portal:

7.1:

{
  "properties": {
    "description": "Test regarding version passed in API during creation",
    "draft": {},
    "logProgress": false,
    "logVerbose": false,
    "runbookType": "PowerShell7"
  }
}

7.2:

{
  "properties": {
    "description": "Test regarding version passed in API during creation",
    "draft": {},
    "logProgress": false,
    "logVerbose": false,
    "runbookType": "PowerShell",
    "runtime": "PowerShell-7.2"
  }
}

@KezHalls
Copy link

Hi, can I also ask when this might be rolled out. with the issues with powershell 5.1 they ask to update to later version as a work around. and now I cannot re-rollout my runbooks with a later version. This really needs to be addressed.

@aristosvo
Copy link
Collaborator

The latest spec contains a runBookType for PowerShell72, which means we could solve the problem.

Let me check if I can make this work!

@davetustin
Copy link

I could also really do with this feature, I need PowerShell 7.

@aristosvo I have faith in you!

@aristosvo aristosvo self-assigned this Nov 20, 2023
@aristosvo aristosvo added upstream/pandora This issue/PR has a dependency on an issue in `github.com/hashicorp/pandora` and removed sdk/not-yet-supported Support for this does not exist in the upstream SDK at this time upstream/pandora This issue/PR has a dependency on an issue in `github.com/hashicorp/pandora` labels Nov 20, 2023
@github-actions github-actions bot added this to the v3.85.0 milestone Dec 14, 2023
@aristosvo
Copy link
Collaborator

Last bit of this issue is fixed in PR #23980, which is just merged and to be released in the next release.

Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 28, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.