FL-LearningGroup / LucasNote

Learn knowledge note
0 stars 0 forks source link

[Az.Automanage] release Api 2022-05-04 version #27

Closed LucasYao93 closed 2 years ago

LucasYao93 commented 2 years ago

Overview

New module, first release.

Work Contents

Perparation

Register-AzResourceProvider -ProviderNamespace Microsoft.Automanage

Other azure resource

Azure Stack HCI

Azure Stack HCI is a hyperconverged infrastructure (HCI) cluster solution that hosts virtualized Windows and Linux workloads and their storage in a hybrid environment that combines on-premises infrastructure with Azure cloud services.

Azure Arc

Today, companies struggle to control and govern increasingly complex environments that extend across data centers, multiple clouds, and edge. Each environment and cloud possesses its own set of management tools, and new DevOps and ITOps operational models can be hard to implement across resources.

How to create Azure arc service

Click add button to generate ps1 script for create Azure arc service image

LucasYao93 commented 2 years ago

New-AzAutomanageConfigurationProfile 👍

Parameter type

change type IAny to Hashtable

New-AzAutomanageConfigurationProfile -Name <String> -ResourceGroupName <String> -Location <String>
 [-SubscriptionId <String>] [-Configuration <IAny>] [-Tag <Hashtable>] [-DefaultProfile <PSObject>]
 [-Confirm] [-WhatIf] [<CommonParameters>]

  - from: swagger-document
    where: $.definitions.ConfigurationDictionary
    transform: >-
      return {
          "description": "The custom configuration for configuration profile. Name and value pairs that define the configuration details of the configuration profile.",
          "type": "object",
          "additionalProperties": true,
          "example": {
            "Antimalware/Enable": true
          }
      }

New-AzAutomanageConfigurationProfile -Name <String> -ResourceGroupName <String> -Location <String>
 [-SubscriptionId <String>] [-Configuration <Hashtable>] [-Tag <Hashtable>] [-DefaultProfile <PSObject>]
 [-Confirm] [-WhatIf] [<CommonParameters>]

Example

$confprof = @{
          "Antimalware/Enable"='false';
          "Backup/Enable"='false';
          "VMInsights/Enable"= 'true';
          "AzureSecurityCenter/Enable"='true';
          "UpdateManagement/Enable"='true';
          "ChangeTrackingAndInventory/Enable"='true';
          "GuestConfiguration/Enable"='true';
          "LogAnalytics/Enable"='true';
          "BootDiagnostics/Enable"='true'
        }
New-AzAutomanageConfigurationProfile -ResourceGroupName automangerg -Name confpro-pwsh01 -Location eastus  -Configuration $confprof

Location Name           ResourceGroupName
-------- ----           -----------------
eastus   confpro-pwsh01 automangerg
LucasYao93 commented 2 years ago

New-AzAutomanageConfigurationProfileAssignment 👍

Parameters

The parameter Name must be "default"

New-AzAutomanageConfigurationProfileAssignment -Name <String> -ResourceGroupName <String> -VMName <String>
 [-SubscriptionId <String>] [-ConfigurationProfile <String>] [-DefaultProfile <PSObject>] [-Confirm] [-WhatIf]
 [<CommonParameters>]

Examples

New-AzAutomanageConfigurationProfileAssignment -ResourceGroupName automangerg -VMName aglinuxvm -ConfigurationProfile "/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"          

Name    ResourceGroupName ManagedBy Status  TargetId
----    ----------------- --------- ------  --------
default automangerg                 Unknown /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/automangerg/providers/Microsoft.Compute/virtualMachines/aglinuxvm
LucasYao93 commented 2 years ago

New-AzAutomanageConfigurationProfileHcrpAssignment 👍

Test

New-AzAutomanageConfigProfileHcrpAssignment -ResourceGroupName lucas-azurearc -MachineName AWP-Lucas -ConfigurationProfile "/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction" -Debug
DEBUG: 11:13:34 AM - GetAzureRMContextCommand end processing.
DEBUG: [CmdletBeginProcessing]: Starting command
DEBUG: CmdletBeginProcessing:
DEBUG: CmdletProcessRecordStart:

Confirm
Are you sure you want to perform this action?
Performing the operation "New-AzAutomanageConfigProfileHcrpAssignment_CreateExpanded" on target "Call remote 'ConfigurationProfileHcrpAssignmentsCreateOrUpdate' operation".
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"): A
DEBUG: CmdletGetPipeline:
DEBUG: CmdletBeforeAPICall:
DEBUG: URLCreated: /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-azurearc/providers/Microsoft.HybridCompute/machines/AWP-Lucas/providers/Microsoft.Automanage/configurationProfileAssignments/default?api-version=2022-05-04
DEBUG: RequestCreated: /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-azurearc/providers/Microsoft.HybridCompute/machines/AWP-Lucas/providers/Microsoft.Automanage/configurationProfileAssignments/default?api-version=2022-05-04
DEBUG: HeaderParametersAdded:
DEBUG: BodyContentSet:
DEBUG: ============================ HTTP REQUEST ============================

HTTP Method:
PUT

Absolute Uri:
https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-azurearc/providers/Microsoft.HybridCompute/machines/AWP-Lucas/providers/Microsoft.Automanage/configurationProfileAssignments/default?api-version=2022-05-04

Headers:
x-ms-unique-id                : 2
x-ms-client-request-id        : 358245ba-2f34-45fb-be8e-2493e29cc1a2
CommandName                   : New-AzAutomanageConfigProfileHcrpAssignment
FullCommandName               : New-AzAutomanageConfigProfileHcrpAssignment_CreateExpanded
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v0.0.0,PSVersion/v7.1.4,Az.Automanage/0.1.0

Body:
{
  "properties": {
    "configurationProfile": "/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"
  }
}

DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
Created

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
Location                      : /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-azurearc/providers/Microsoft.HybridCompute/machines/AWP-Lucas/providers/Microsoft.Automanage/configurationProfileAssignments/default
Request-Context               : appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d
Strict-Transport-Security     : max-age=31536000; includeSubDomains
Server                        : Kestrel
x-ms-ratelimit-remaining-subscription-writes: 1199
x-ms-request-id               : fa8e9941-6b47-4a5d-9c62-f16db7fd8560
x-ms-correlation-request-id   : fa8e9941-6b47-4a5d-9c62-f16db7fd8560
x-ms-routing-request-id       : SOUTHEASTASIA:20221019T031337Z:fa8e9941-6b47-4a5d-9c62-f16db7fd8560
X-Content-Type-Options        : nosniff
Date                          : Wed, 19 Oct 2022 03:13:37 GMT

Body:
{
  "id": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-azurearc/providers/Microsoft.HybridCompute/machines/AWP-Lucas/providers/Microsoft.Automanage/configurationProfileAssignments/default",
  "name": "default",
  "type": "Microsoft.Automanage/configurationProfileAssignments",
  "properties": {
    "targetId": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-azurearc/providers/Microsoft.HybridCompute/machines/AWP-Lucas",
    "configurationProfile": "/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction",
    "status": "New"
  },
  "systemData": {
    "createdAt": "2022-10-19T11:13:35.7747933+08:00",
    "createdBy": "v-diya@microsoft.com",
    "createdByType": "User",
    "lastModifiedAt": "2022-10-19T11:13:35.7747933+08:00",
    "lastModifiedBy": "v-diya@microsoft.com",
    "lastModifiedByType": "User"
  }
}

DEBUG: ResponseCreated:
DEBUG: BeforeResponseDispatch:

DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: AzureQoSEvent: Module: Az.Automanage:0.1.0; CommandName: New-AzAutomanageConfigProfileHcrpAssignment; PSVersion: 7.1.4; IsSuccess: True; Duration: 00:00:04.1727480
Name    ResourceGroupName ManagedBy Status TargetId
----    ----------------- --------- ------ --------
default lucas-azurearc              New    /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/lucas-azurearc/providers/Microsoft.HybridCompute/machines/AWP-Lucas
LucasYao93 commented 2 years ago

New-AzAutomanageConfigurationProfileHciAssignment ❌

Test

HTTP Method:
PUT

Absolute Uri:
https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/automangerg/providers/Microsoft.AzureStackHci/clusters/aglinuxvm/providers/Microsoft.Automanage/configurationProfileAssignments/default?api-version=2022-05-04

Headers:
x-ms-unique-id                : 2
x-ms-client-request-id        : ac44d193-6e03-45d7-a8a5-f2b931d02108
CommandName                   : New-AzAutomanageConfigurationProfileHciAssignment
FullCommandName               : New-AzAutomanageConfigurationProfileHciAssignment_CreateExpanded
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v0.0.0,PSVersion/v7.1.4,Az.Automanage/0.1.0

Body:
{
  "properties": {
    "configurationProfile": "/providers/Microsoft.Automanage/bestPractices/AzureBestPracticesProduction"
  }
}

DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
NotFound

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
x-ms-failure-cause            : gateway
x-ms-request-id               : e275d56b-9a3e-4cd1-9104-9cfb88c0daf1
x-ms-correlation-request-id   : e275d56b-9a3e-4cd1-9104-9cfb88c0daf1
x-ms-routing-request-id       : SOUTHEASTASIA:20220909T063304Z:e275d56b-9a3e-4cd1-9104-9cfb88c0daf1
Strict-Transport-Security     : max-age=31536000; includeSubDomains
X-Content-Type-Options        : nosniff
Date                          : Fri, 09 Sep 2022 06:33:03 GMT

Body:
{
  "error": {
    "code": "ResourceNotFound",
    "message": "The Resource 'Microsoft.AzureStackHci/clusters/aglinuxvm' under resource group 'automangerg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"
  }
}

DEBUG: ResponseCreated: 
DEBUG: BeforeResponseDispatch:
DEBUG: CmdletProcessRecordEnd:
New-AzAutomanageConfigurationProfileHciAssignment_CreateExpanded: The Resource 'Microsoft.AzureStackHci/clusters/aglinuxvm' under resource group 'automangerg' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix

Result

Our subscription unsupport api.

LucasYao93 commented 2 years ago

New-AzAutomanageConfigurationProfileVersion ❌ (the service unsupport)

LucasYao93 commented 2 years ago

❌ Get-AzAutomanageBestPracticesVersion and Get-AzAutomanageBestPracticesVersion not merge together

Get-AzAutomanageBestPracticesVersion operation id: "BestPracticesVersions_Get" https://github.com/Azure/azure-rest-api-specs/blob/main/specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/automanage.json#L118

Get-AzAutomanageBestPracticeVersion operation id: "BestPracticesVersions_ListByTenant" https://github.com/Azure/azure-rest-api-specs/blob/main/specification/automanage/resource-manager/Microsoft.Automanage/stable/2022-05-04/automanage.json#L171

LucasYao93 commented 2 years ago

Get-AzAutomanageConfigurationProfileAssignment

Has some variant

Get

Get-AzAutomanageConfigurationProfileAssignment -ResourceGroupName <String> -VMName <String>
 [-SubscriptionId <String[]>] [-DefaultProfile <PSObject>] [<CommonParameters>]

List

Get-AzAutomanageConfigurationProfileAssignment -ResourceGroupName <String> -VMName <String>
 [-SubscriptionId <String[]>] [-DefaultProfile <PSObject>] [<CommonParameters>]
LucasYao93 commented 2 years ago

Get-AzAutomanageReport ❌

Test

Get-AzAutomanageReport -ConfigurationProfileAssignmentName default -ResourceGroupName automangerg -VMName aglinuxvm                                                          

Name                                         ResourceGroupName
----                                         -----------------
default/a261e96e-90bd-4feb-bed6-c9e1fb436d51 automangerg
default/787969f2-d8b2-4f33-afb3-f3636880884e automangerg
default/638cc61a-70d9-4a88-9ffc-f5a49e981dd7 automangerg
default/8cbcf4be-6f16-480b-85ac-4c0392ff0476 automangerg
default/20640074-b8fd-4e27-abc3-7c9440ea40db automangerg
default/0a9e1d06-6903-4580-8876-84ab7be07239 automangerg
default/6ae85795-33c1-45e9-8823-3124e53378ab automangerg
default/ec6183de-759e-4db2-ae94-142d0d65c33a automangerg
default/7a865a92-8000-49ef-9765-b843055619b2 automangerg
default/5a9a12ec-c63f-45cc-9568-0e15e89b61e0 automangerg
default/af0fa24c-35d2-420d-a46b-f0fe378cf015 automangerg
default/4960c434-aa36-4072-ad67-32f2a6f25472 automangerg
default/0ffe854d-9bba-4221-bb3f-8f1c98ae749b automangerg
default/5c768928-2bd9-4d17-a414-bbd59dbd1430 automangerg
default/2bae3a13-1dbb-4846-9e99-0c375163ac79 automangerg
default/d9ec093d-5ac2-40f2-b065-2e319f077907 automangerg
default/65fa937d-1c19-4ed1-b17c-f4153d5433e1 automangerg
default/73eeacd1-5ba5-43a9-b767-a09cfd0e6397 automangerg
default/5d807444-26a6-4f79-babc-3b9c4aef0415 automangerg
default/c94c9d0f-0cf5-4ead-aab4-19220f7f5546 automangerg
default/77c8bf69-e215-4c11-a832-22eaf09f1fcf automangerg
default/01d109d8-0567-4d28-94ac-0dc22147602c automangerg
default/cdac0802-8244-475e-b03b-dcc6a36801a3 automangerg
default/e1dd537c-9834-4afa-9c97-94cf5f92f106 automangerg
default/a2c5fc48-60ff-4f97-9a09-0eda810633cd automangerg
default/741239dd-1da4-451a-a3bb-719dd1d5c23b automangerg
default/cb830d21-e75d-4617-92b5-3a9fca616613 automangerg
default/0116a363-988a-417d-a162-26c1f0a819b4 automangerg
default/b360fe91-8d19-45d1-b62b-40a5aef44f59 automangerg
default/feb6eeaa-3d3f-4777-b20c-e6427969d554 automangerg
default/501031b2-2ee2-41b8-aff6-d0ec39ead1e7 automangerg
default/2fc62f07-313f-468e-8460-054d8b8419d5 automangerg
default/39851611-d6f1-4b98-a750-d4348d901f28 automangerg
default/2542cf05-51a7-4cf8-8c8c-c3ddacea915d automangerg
default/aa15c896-46d6-4508-aeeb-d8d84d206eab automangerg

Get-AzAutomanageReport -ConfigurationProfileAssignmentName default -ResourceGroupName automangerg -VMName aglinuxvm -Name default/a261e96e-90bd-4feb-bed6-c9e1fb436d51       
Get-AzAutomanageReport_Get: The server responded with a Request Error, Status: NotFound

Get-AzAutomanageReport -ConfigurationProfileAssignmentName default -ResourceGroupName automangerg -VMName aglinuxvm -Name a261e96e-90bd-4feb-bed6-c9e1fb436d51        

Name                                         ResourceGroupName
----                                         -----------------
default/a261e96e-90bd-4feb-bed6-c9e1fb436d51 automangerg

============================ HTTP REQUEST ============================

HTTP Method:
GET

Absolute Uri:
https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/automangerg/providers/Microsoft.Compute/virtualMachines/aglinuxvm/providers/Microsoft.Automanage/configurationProfileAssignments/default/reports/a261e96e-90bd-4feb-bed6-c9e1fb436d51?api-version=2022-05-04

Headers:
x-ms-unique-id                : 2
x-ms-client-request-id        : 8cce4940-790d-4ff3-97ed-c60cfeceba20
CommandName                   : Get-AzAutomanageReport
FullCommandName               : Get-AzAutomanageReport_Get
ParameterSetName              : __AllParameterSets
User-Agent                    : AzurePowershell/v0.0.0,PSVersion/v7.1.4,Az.Automanage/0.1.0

Body:

DEBUG: BeforeCall:
DEBUG: ============================ HTTP RESPONSE ============================

Status Code:
OK

Headers:
Cache-Control                 : no-cache
Pragma                        : no-cache
Request-Context               : appId=cid-v1:a4d240dc-d543-4b4e-a019-0a571290b85d
Strict-Transport-Security     : max-age=31536000; includeSubDomains
Server                        : Kestrel
x-ms-ratelimit-remaining-subscription-reads: 11997
x-ms-request-id               : 7eb69bd6-04ee-4358-90d1-cc879dc83e2b
x-ms-correlation-request-id   : 7eb69bd6-04ee-4358-90d1-cc879dc83e2b
x-ms-routing-request-id       : SOUTHEASTASIA:20220916T013716Z:7eb69bd6-04ee-4358-90d1-cc879dc83e2b
X-Content-Type-Options        : nosniff
Date                          : Fri, 16 Sep 2022 01:37:15 GMT

Body:
{
  "id": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/automangerg/providers/Microsoft.Compute/virtualMachines/aglinuxvm/providers/Microsoft.Automanage/configurationProfileAssignments/default/reports/a261e96e-90bd-4feb-bed6-c9e1fb436d51",
  "name": "default/a261e96e-90bd-4feb-bed6-c9e1fb436d51",
  "type": "Microsoft.Automanage/configurationProfileAssignments/reports",
  "properties": {
    "startTime": "2022-09-08T06:56:48.5838589Z",
    "endTime": "2022-09-08T06:56:49.6157195Z",
    "lastModifiedTime": "2022-09-08T06:56:49.6157193Z",
    "duration": "PT1.0318606S",
    "type": "Consistency",
    "status": "Unknown",
    "configurationProfile": null,
    "resources": [],
    "error": {
      "code": "UnableToRetrieveRequiredResource",
      "message": "Unable to a retrieve resource. The appropriate permissions may not be completely configured.",
      "target": "/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/automangerg",
      "details": null,
      "additionalInfo": [
        {
          "type": "hyperlink",
          "info": "https://aka.ms/automanage-rbac"
        }
      ]
    },
    "reportFormatVersion": null
  },
  "systemData": {
    "createdAt": "2022-09-08T14:56:50.5208622+08:00",
    "createdBy": "d828acde-4b48-47f5-a6e8-52460104a052",
    "createdByType": "Application",
    "lastModifiedAt": "2022-09-08T14:56:50.5208622+08:00",
    "lastModifiedBy": "d828acde-4b48-47f5-a6e8-52460104a052",
    "lastModifiedByType": "Application"
  }
}

DEBUG: ResponseCreated: 
DEBUG: BeforeResponseDispatch:

DEBUG: Finally:
DEBUG: CmdletAfterAPICall:
DEBUG: [CmdletProcessRecordAsyncEnd]: Finish HTTP process
DEBUG: CmdletProcessRecordAsyncEnd:
DEBUG: CmdletProcessRecordEnd:
DEBUG: AzureQoSEvent: Module: Az.Automanage:0.1.0; CommandName: Get-AzAutomanageReport; PSVersion: 7.1.4; IsSuccess: True; Duration: 00:00:00.6352220

Result

First release, Wait service fix it.

LucasYao93 commented 2 years ago

Update-AzAutomanageConfigProfile ❌

Test

Update-AzAutomanageConfigProfile -ResourceGroupName automangerg -Name confpro-pwsh01 -Tag @{"Organization"="Administration"} -Debug DEBUG: 4:35:34 PM - GetAzureRMContextCommand end processing. DEBUG: [CmdletBeginProcessing]: Starting command DEBUG: CmdletBeginProcessing: DEBUG: CmdletProcessRecordStart:

Confirm Are you sure you want to perform this action? Performing the operation "Update-AzAutomanageConfigProfile_UpdateExpanded" on target "Call remote 'ConfigurationProfilesUpdate' operation". [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "Y"): A DEBUG: CmdletGetPipeline: DEBUG: CmdletBeforeAPICall: DEBUG: URLCreated: /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/automangerg/providers/Microsoft.Automanage/configurationProfiles/confpro-pwsh01?api-version=2022-05-04 DEBUG: RequestCreated: /subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/automangerg/providers/Microsoft.Automanage/configurationProfiles/confpro-pwsh01?api-version=2022-05-04 DEBUG: HeaderParametersAdded: DEBUG: BodyContentSet: DEBUG: ============================ HTTP REQUEST ============================

HTTP Method: PATCH

Absolute Uri: https://management.azure.com/subscriptions/9e223dbe-3399-4e19-88eb-0975f02ac87f/resourceGroups/automangerg/providers/Microsoft.Automanage/configurationProfiles/confpro-pwsh01?api-version=2022-05-04

Headers: x-ms-unique-id : 5 x-ms-client-request-id : 02d7f32d-0c3f-45e7-8823-0be8dafaf42d CommandName : Update-AzAutomanageConfigProfile FullCommandName : Update-AzAutomanageConfigProfile_UpdateExpanded ParameterSetName : __AllParameterSets User-Agent : AzurePowershell/v0.0.0,PSVersion/v7.1.4,Az.Automanage/0.1.0

Body: { "tags": { "Organization": "Administration" } }

DEBUG: BeforeCall: DEBUG: ============================ HTTP RESPONSE ============================

Status Code: InternalServerError

Headers: Cache-Control : no-cache Pragma : no-cache Server : Kestrel x-ms-failure-cause : service x-ms-ratelimit-remaining-subscription-writes: 1199 x-ms-request-id : 9384bd2a-fecc-4acf-9788-58114baf2cc0 x-ms-correlation-request-id : 9384bd2a-fecc-4acf-9788-58114baf2cc0 x-ms-routing-request-id : SOUTHEASTASIA:20221008T083537Z:9384bd2a-fecc-4acf-9788-58114baf2cc0 Strict-Transport-Security : max-age=31536000; includeSubDomains X-Content-Type-Options : nosniff Date : Sat, 08 Oct 2022 08:35:37 GMT Connection : close

Body:

DEBUG: ResponseCreated: DEBUG: BeforeResponseDispatch: DEBUG: CmdletProcessRecordEnd:

LucasYao93 commented 2 years ago

Az.Automanage has been released.