Closed jhoelzl closed 3 years ago
This is not documented but you can solve by adding the following ENV
IDENTITY_ENDPOINT=https://your-vault-url.vault.azure.net
Unfortunately this does not help. It is confusing since from the same Host (Azure VM) it works with Python, but not with PHP.
From another Azure Webapp (PHP) it works with your library.
Maybe there are some differences in the PHP versions or settings.
@jhoelzl you need to extend the Client if you are not using managed identity.
for example, you would override the the Client's getAccessToken to authenticate via the service principal credentials. Then create Secret with the Client. (more detail on the official docs.)
new Secret("https://your-vault-name.vault.azure.net", new Client());
class Client extends AzKeyVaultClient
{
public function __construct()
{
parent::__construct();
$this->client = $this->getClient();
$this->accessToken = $this->getAccessToken();
}
protected function getAccessToken(): string
{
$resource = 'https://vault.azure.net';
[$tenantId, $clientId, $clientSecret] = $this->getAzureConfig();
$tokenUrl = "https://login.microsoftonline.com/$tenantId/oauth2/token";
Hi @jhoelzl
The newest release adds support for running this package in Azure VM's. But as @litan1106 correctly pointed out this only works with managed identity. If you have user-assigned identities you'd need to override the getAccessToken
method in the client.
Okay, thank you guys for the support. As the lib works from the webapp but not in my VM (although the VM has access to the keyvault through managed identity), i think it is another problem, therefore i close this issue.
Okay, thank you guys for the support. As the lib works from the webapp but not in my VM (although the VM has access to the keyvault through managed identity), i think it is another problem, therefore i close this issue.
NP. I always use the Service Principal's credential to authenticate. (This lib is super flex with custom extended Client.)
The initialization of the my keyvault
$secret = new AzKeyVault\Secret('https://my-custom.vault.azure.net/');
causes this error:
GMP is installed, the command
php -info | grep "GMP"
returnsAlso the application is allowed to access the keyvault through service principal.
Versions of installed packages:
Do you have any suggestions?