Hello everyone, I am making a python script that will create an Azure Dashboard (that is working fine) but if another dashboard is requested with the same name as an existing one, the script should tell the user something like "A dashboard with that name already exists", for checking if the dashboard already exist I am using the "check_existence_by_id" for resources (using the Python SDK).
My problem is that no matter if the dashboard exists or not, the method is always returning "false", I tried with multiple APIs (as the API version is required for this method) and of course the ResourceID I am using is correct, I checked it in the Azure Portal.
Here is the code I am using:
from azure.identity import DefaultAzureCredential
from azure.mgmt.resource import ResourceManagementClient
credential = DefaultAzureCredential()
resource_client = ResourceManagementClient(credential=credential, subscription_id='xxxxxxxxx-xxxx-xxxxx-xxxxx-xxxxxxxxxxxxxxxx')
Dashboard_Resource_Id='/subscriptions/xxxxxxxxx-xxxx-xxxxx-xxxxx-xxxxxxxxxxxxxxxx/resourceGroups/someresourcegroup/providers/Microsoft.Portal/dashboards/MetricDashboard'
resource_client.resources.check_existence_by_id(resource_id=Dashboard_Resource_Id,api_version='2015-08-01-preview')
I am passing credentials using environment variables so the authentication works, I checked this because the script actually creates the dashboard, but the second time I run it as it returnd "false" when asking if the dashboard exists, it tries to create the dashboard again.
Could anyone point me in the right direction on this? why is this method not working for the dashboard but seems to work fine for other resources (like storage accounts).
Thank you very much for any information or tips!