JulianHayward / Azure-MG-Sub-Governance-Reporting

Azure Governance Visualizer aka AzGovViz is a PowerShell script that captures Azure Governance related information such as Azure Policy, RBAC (a lot more) by polling Azure ARM, Storage and Microsoft Graph APIs.
MIT License
814 stars 293 forks source link

The resource type could not be found in the namespace 'microsoft.datafactory' for api version '2021-05-01-preview #216

Closed hli07 closed 8 months ago

hli07 commented 8 months ago

AzGovViz version v6_major_20230330_1

CodeRunPlatform Azure DevOps

Describe the bug [AzAPICallErrorHandler 1.1.72] Checking if ResourceType 'microsoft.datafactory/datafactories' is capable for Resource Diagnostics using 1 ResourceId: '/subscriptions/xxx-xxx-xxx-xxx-xxx/resourcegroups/atsselfservicegroup/providers/microsoft.datafactory/datafactories/copyfactory-78x' try #1; return: (StatusCode: '404' (NotFound)) <.code: ''> <.error.code: 'InvalidResourceType'> | <.message: ''> <.error.message: #'The resource type could not be found in the namespace 'microsoft.datafactory' for api version '2021-05-01-preview'.'> - unhandledErrorAction: Stop Exception: /home/vsts/work/1/s/pwsh/AzGovVizParallel.ps1:4028 Line | 4028 | $microsoftResourceTypes | ForEach-Object -Parallel { | ~~~~~~~~~~~~ | Error - check the last console output for details

[error]PowerShell exited with code '1'.

Screenshots

Screenshot 2023-11-08 at 18 09 26

Additional context I can confirm that the actual datafactory azure resource called: copyfactory-78x does not exist anymore. But why would it reminisce about it when its not there anymore. Does it maybe have to do with the api version '2021-05-01-preview?

JulianHayward commented 8 months ago

@hli07 thanks for reporting, let me fix that AzAPICall ref handler - meanwhile deleted resources are actually handled but in this case the errorcode seems to deviate from the yet known standard(s) :) ), I guess that in the next run the error will disappear as the resource will not be picked up.. let me know.

hli07 commented 8 months ago

Hi @JulianHayward, thank you very much for the prompt response.

I have a azure pipeline thats scheduled to run every day twice but only noticed the failure today.

I guess that in the next run the error will disappear as the resource will not be picked up.. let me know. So looking into the last working pipeline which was on the 22st September 2023, it has failing ever since, meaning up to today

JulianHayward commented 8 months ago

@hli07 hmm, always with this error then I assume?

What if you run this against that sub/rg is the meanwhile deleted resource getting listed?

Get-AzResource -ResourceGroupName testRG 

or even better if you try with the api: https://learn.microsoft.com/en-us/rest/api/resources/resources/list?view=rest-resources-2021-04-01

azgvz ref

hli07 commented 8 months ago

@hli07 hmm, always with this error then I assume?

What if you run this against that sub/rg is the meanwhile deleted resource getting listed?

Get-AzResource -ResourceGroupName testRG 

or even better if you try with the api: https://learn.microsoft.com/en-us/rest/api/resources/resources/list?view=rest-resources-2021-04-01

azgvz ref

So all the scheduled pipelines had failed with the same error:

Screenshot 2023-11-08 at 20 01 34

Now I ran the pipeline manually:

Screenshot 2023-11-08 at 20 02 25

First manually run pipeline error: Exception: /home/vsts/work/1/s/pwsh/AzGovVizParallel.ps1:29124 Line | 29124 | … throw " Installing '$($module.ModuleName)' module ($($mo … | ~~~~~~~~~~~~~ | Installing 'AzAPICall' module (1.1.72) failed

Second manually run pipeline: Still running, will be able to tell more after 20m+

hli07 commented 8 months ago

Hi @JulianHayward, so the good news is, the pipeline is still running and also past to the point where it failed before.

Screenshot 2023-11-08 at 20 29 53

It seems the pipeline succeeded!

Screenshot 2023-11-08 at 20 46 23
hli07 commented 8 months ago

I got another pipeline with another goviz webapp failing but with a different error (see below) that I posted for this issue. I ran that pipeline manually multiple times and got this error:

Exception: /home/vsts/work/1/s/pwsh/AzGovVizParallel.ps1:34129
 Line |
34129 |              Throw $throwmsg
      |              ~~~~~~~~~~~~~~~
      | 0 'Available Private Endpoint Types' - Please use another Subscription
      | for the AzContext (current subscriptionId:
      | 'xxx-xxx-xxx-xxx-xxx') -> use parameter:
      | -SubscriptionId4AzContext '<subscriptionId>'

##[error]PowerShell exited with code '1'.

Quick question on this error, I have noticed in the variables that this is randomised

  # Define the Subscription Id to use for AzContext (default is to use a **random Subscription Id**)
  - name: SubscriptionId4AzContext
    # String | example: value: "<your-Subscription-Id>"
    value:

Is it better to always by default point to a (if existing) subscription or leave it empty? What from I am seeing is if I don't point to a subscription, this error will always re-occur, since I ran the pipeline multiple times and it somehow ended up using the same subscription?

@JulianHayward apologise if I am imposing on this issue to another issue, do you want me to create another issue or could we continue here?

hli07 commented 8 months ago

I guess I have solved my own problems lol, but thanks anyways @JulianHayward :)