My notes from ChatGPT: List of Cancer hospitals in India

Here is a list of some well-known cancer hospitals in India: Tata Memorial Hospital, Mumbai : One of the oldest and most reputed cancer hospitals in India, known for its comprehensive cancer care and research. All India Institute of Medical Sciences (AIIMS), New Delhi : AIIMS is a premier medical institute in India with a dedicated cancer treatment center that offers advanced care and research facilities. Adyar Cancer Institute, Chennai : Known for its expertise in cancer treatment and research, particularly in radiation oncology and surgical oncology. Rajiv Gandhi Cancer Institute and Research Centre, Delhi : A leading cancer hospital providing comprehensive cancer care with state-of-the-art facilities. Cancer Institute (WIA), Chennai : Founded by Dr. Muthulakshmi Reddy, it is one of the oldest cancer hospitals in India, known for its pioneering work in cancer treatment and research. Apollo Hospitals, Chennai : Part of the Apollo Group, it offers specialized cancer care across various...

Resolved Error - Azure Powershell failed to get token from Token Cache. Getting You cannot call a method on a null-valued expression

 Recently, I was working on an Azure Powershell Script in which I was getting the Cached Token and it was working fine for a long time and it started failing recently.

Here is the code that I was using in my powershell script:

    Write-Host "Getting Az Context"
    $azContext = Get-AzContext
    Write-Host "Displaying context"

    #$rmAccount = Add-AzureRmAccount -SubscriptionId $subscriptionId 
    #$tenantId = $azureRmContext.Tenant.Id
    $tokenCache = $azContext.TokenCache
    $cachedTokens = $tokenCache.ReadItems() `
        #| where { $_.TenantId -eq $tenantId } `
        Sort-Object -Property ExpiresOn -Descending
	
    $cachedTokens[0].AccessToken
  

Now, I started getting the error "You cannot call a method on a null-valued expression". I was clear that my Token Cache is getting expired and then I googled about the issue and I find the following useful github links: And finally, I implemented the following solution:

Solution:

    $currentAzureContext = Get-AzContext
    $azureRmProfile = [Microsoft.Azure.Commands.Common.Authentication.Abstractions.AzureRmProfileProvider]::Instance.Profile;
    $profileClient = New-Object Microsoft.Azure.Commands.ResourceManager.Common.RMProfileClient($azureRmProfile);
    $profileClient.AcquireAccessToken($currentAzureContext.Subscription.TenantId).AccessToken;