コード例 #1
0
ファイル: RbacClient.cs プロジェクト: robzelt/ASC
        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
ファイル: RbacClient.cs プロジェクト: robzelt/ASC
        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
ファイル: PoliciesClient.cs プロジェクト: robzelt/ASC
        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));
        }