Skip to content

Instantly share code, notes, and snippets.

@SyntaxC4 SyntaxC4/composer.json
Last active Aug 29, 2015

Embed
What would you like to do?
Interacting with the Windows Azure Management API with Guzzle PHP
{
"require": {
"guzzle/guzzle": "~3.1"
}
}
{
"HostNameSslStates": [
{
"Name": "[custom-domain-name]",
"SslState": 0,
"Thumbprint": "[ssl-certificate-thumbprint]",
"ToUpdate": "true"
}
]
}
<Site xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HostNameSslStates>
<HostNameSslState>
<Name>[custom-domain-name]</Name>
<SslState>Disabled</SslState>
<Thumbprint>[ssl-certificate-thumbprint]</Thumbprint>
<ToUpdate>true</ToUpdate>
</HostNameSslState>
</HostNameSslStates>
</Site>
{
"HostNameSslStates": [
{
"Name": "[custom-domain-name]",
"SslState": 1,
"Thumbprint": "[ssl-certificate-thumbprint]",
"ToUpdate": "true"
}
]
}
<Site xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<HostNameSslStates>
<HostNameSslState>
<Name>[custom-domain-name]</Name>
<SslState>SniEnabled</SslState>
<Thumbprint>[ssl-certificate-thumbprint]</Thumbprint>
<ToUpdate>true</ToUpdate>
</HostNameSslState>
</HostNameSslStates>
</Site>
<?php
require_once "vendor/autoload.php";
use Guzzle\Http\Client;
$client = new Client(
'https://management.core.windows.net:443/',
array(
'subscription' => '[SUBSCRIPTION-ID]',
'webspace' => '[webspace-name]', // eastuswebspace | westuswebspace |
'site' => '[web-site-name]',
'curl.options' => array (
'CURLOPT_SSLCERT' => '[path-to-pem-certificate]'
)
)
);
$client->setDefaultHeaders(
array (
'x-ms-version' => '2012-10-10',
'accept' => 'application/json'
)
);
try {
$request = $client->put('{subscription}/services/WebSpaces/{webspace}/sites/{site}');
$request->setBody(fopen([path-to-payload], 'r')); // You can replace this with a string version of the payload
$response = $request->send();
echo $response->getBody();
} catch (Exception $ex) {
echo $ex;
}

Create Client (*.pem) Certificate

openssl req -x509 -nodes -days 365 -newkey rsa:1024 -keyout mycert.pem -out mycert.pem

Create Server (*.cer) Certificate

openssl x509 -inform pem -in mycert.pem -outform der -out mycert.cer

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.