You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Motivation
In order to fetch the resources we have multiple solution paths:
Write fetchers for every resource type
Utilize Azure resource graph capabilities
The focus is to have something similar to asset inventory and avoid writing fetchers.
This is why I've focused on the ARG and implemented a small POC in order to see if it is a viable option.
// Licensed to Elasticsearch B.V. under one or more contributor// license agreements. See the NOTICE file distributed with// this work for additional information regarding copyright// ownership. Elasticsearch B.V. licenses this file to you under// the Apache License, Version 2.0 (the "License"); you may// not use this file except in compliance with the License.// You may obtain a copy of the License at//// http://www.apache.org/licenses/LICENSE-2.0//// Unless required by applicable law or agreed to in writing,// software distributed under the License is distributed on an// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY// KIND, either express or implied. See the License for the// specific language governing permissions and limitations// under the License.package main
import (
"context""fmt""log""github.com/Azure/azure-sdk-for-go/sdk/azcore/to""github.com/Azure/azure-sdk-for-go/sdk/azidentity""github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/resourcegraph/armresourcegraph"
)
funcmain() {
cred, err:=azidentity.NewDefaultAzureCredential(nil)
iferr!=nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx:=context.Background()
clientFactory, err:=armresourcegraph.NewClientFactory(cred, nil)
iferr!=nil {
log.Fatalf("failed to create client: %v", err)
}
res, err:=clientFactory.NewClient().Resources(ctx, armresourcegraph.QueryRequest{
// Query: to.Ptr("Resources | where type =~ 'Microsoft.Storage/StorageAccounts' | limit 1"),Query: to.Ptr("Resources"),
Subscriptions: []*string{
to.Ptr("SUB_ID")},
}, nil)
iferr!=nil {
log.Fatalf("failed to finish the request: %v", err)
}
fmt.Printf("%v", res.Data)
}
Running this on my subscription resulted in a response with all of the resources inside the subscription.
There is also an option to run the queries on management groups.
Definition of done
What needs to be completed at the end of this task
Implement fetching of resources using ARG with pagination
Support management groups
The text was updated successfully, but these errors were encountered:
Motivation
In order to fetch the resources we have multiple solution paths:
The focus is to have something similar to asset inventory and avoid writing fetchers.
This is why I've focused on the ARG and implemented a small POC in order to see if it is a viable option.
Running this on my subscription resulted in a response with all of the resources inside the subscription.
There is also an option to run the queries on management groups.
Definition of done
What needs to be completed at the end of this task
The text was updated successfully, but these errors were encountered: