Пример #1
0
        public async Task <string> GetRoleByName(string subscriptionId, string resourceGroup, string roleName)
        {
            var requestUrl = $"{Config.AzureResourceManagerUrl}/subscriptions/{subscriptionId}/resourceGroups/{resourceGroup}/providers/Microsoft.Authorization/roleDefinitions?api-version={apiVersion}&$filter=roleName%20eq%20'{roleName}'";
            var response   = await ArmHttpClient.Get(requestUrl);

            return(response);
        }
Пример #2
0
        public static async Task <string> GetAuditLogs(string subscriptionId, string correlationId)
        {
            const string apiVersion = "2014-04-01";
            var          timestamp  = DateTime.Now.Subtract(TimeSpan.FromDays(30)).ToString("yyyy-MM-ddT00:00:00Z");
            var          requestUrl = $"{Config.AzureResourceManagerUrl}/subscriptions/{subscriptionId}/providers/microsoft.insights/eventtypes/management/values?api-version={apiVersion}&$filter=eventTimestamp ge '{timestamp}' and correlationId eq '{correlationId}'";
            var          response   = await ArmHttpClient.Get(requestUrl);

            return(response);
        }
Пример #3
0
        public async Task <string> GetRoleAssignmentsForAscContributor(string subscriptionId)
        {
            var ascContributorRole = await this.GetAscContributorRole(subscriptionId);

            var requestUrl = $"{Config.AzureResourceManagerUrl}/subscriptions/{subscriptionId}/providers/Microsoft.Authorization/roleAssignments?api-version={apiVersion}&filter=atScope()";
            var response   = await ArmHttpClient.Get(requestUrl);

            dynamic roleAssignments    = JObject.Parse(response);
            var     items              = roleAssignments.value as IEnumerable <dynamic>;
            var     ascRoleAssignments = items.Where(x => x.properties.roleDefinitionId == ascContributorRole.id).ToList();

            return(ascRoleAssignments.ToJArray().ToString());
        }
Пример #4
0
        public async Task <string> GetPolicyAssignment(string subscriptionId, string policyAssignmentName)
        {
            var requestUrl = $"{Config.AzureResourceManagerUrl}/subscriptions/{subscriptionId}/providers/Microsoft.authorization/policyassignments/{policyAssignmentName}?api-version={policyApiVersion}";

            return(await ArmHttpClient.Get(requestUrl));
        }