Skip to content

Instantly share code, notes, and snippets.

@SyntaxC4
Last active August 29, 2015 13:56
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save SyntaxC4/9162353 to your computer and use it in GitHub Desktop.
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