Check the size of AD Connect MS SQL Express database

MS SQL Express has database size limit of 10 Gb, so how to know when to switch to another edition of MS SQL?

To check current database size of AD Connect you can use following commands:

>"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SqlLocalDB.exe" info .\ADSync
Name:               ADSync
Shared name:        ADSync
Owner:              NT SERVICE\ADSync
Instance pipe name: np:\\.\pipe\LOCALDB#SHD66A55\tsql\query

>"C:\Program Files\Microsoft SQL Server\110\Tools\Binn\SQLCMD.EXE" -S "np:\\.\pipe\LOCALDB#SHD66A55\tsql\query" -Q "sp_helpdb ADSync;" > ADSync.txt

You can also connect to ADSync database with Invoke-Sqlcmd cmdlet from SQLPS PowerShell module:

Invoke-Sqlcmd -ServerInstance "(localdb)\.\AdSync" -Query 'sp_helpdb ADSync'

iptables – source host not found

If you see something like:

iptables v1.4.21: host/network `proxy.ovh.net' not found
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.21: host/network `proxy.p19.ovh.net' not found
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.21: host/network `proxy.rbx.ovh.net' not found
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.21: host/network `proxy.sbg.ovh.net' not found
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.21: host/network `proxy.bhs.ovh.net' not found
Try `iptables -h' or 'iptables --help' for more information.
iptables v1.4.21: host/network `ping.ovh.net' not found
Try `iptables -h' or 'iptables --help' for more information.

Authorize your DNS traffic before :


#
# ...
#

# DNS
/sbin/iptables -t filter -A OUTPUT -p tcp --dport 53 -j ACCEPT
/sbin/iptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPT
/sbin/iptables -t filter -A INPUT -p tcp --dport 53 -j ACCEPT
/sbin/iptables -t filter -A INPUT -p udp --dport 53 -j ACCEPT

/sbin/iptables -A INPUT -i eth0 -p icmp --source proxy.ovh.net -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -p icmp --source proxy.p19.ovh.net -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -p icmp --source proxy.rbx.ovh.net -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -p icmp --source proxy.sbg.ovh.net -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -p icmp --source proxy.bhs.ovh.net -j ACCEPT

#
# ...
#

Python 3.5 Essentials – 1. Output

When you are trying to learn a new language it is always better if you will see a practical real life result. Let’s try to learn Python from zero and develop a chess game.

The first topic to onboard is Output, because it is the only one way for human to get a result of program execution. For our first programs we will use a text output on screen to console (terminal).

For this series of articles I am using Ubuntu 16.04 where Python 2.7.12 and Python 3.5.2 are preinstalled.  I will write an article to make an instructions for using examples on Windows.

To print some text on the screen we should use print() function in Python. You can create chess0.py text file with following code:

print(" abcdefgh ")
print("8RNBQKBNR8")
print("7PPPPPPPP7")
print("6        6")
print("5        5")
print("4        4")
print("3        3")
print("2PPPPPPPP2")
print("1RNBQKBNR1")
print(" abcdefgh ")

To run this code, open console and type following command:

python3 chess0.py

Now, Python 3.5 will interpret your code and print the chessboard on the screen:

 abcdefgh 
8RNBQKBNR8
7PPPPPPPP7
6        6
5        5
4        4
3        3
2PPPPPPPP2
1RNBQKBNR1
 abcdefgh

Usually any console is using monospaced fixed-width fonts, so, all characters should be well aligned.  But i=even if we can understand the figures it does not looks like a chessboard. To make it more realistic we can use escape sequences. Now you can modify your code to add right background colors for chessboard cells:

print("  abcdefgh  ")
print("8 \x1b[38;5;232m\x1b[48;5;231mR\x1b[0m\x1b[38;5;231m\x1b[48;5;232mN\x1b[0m\x1b[38;5;232m\x1b[48;5;231mB\x1b[0m\x1b[38;5;231m\x1b[48;5;232mQ\x1b[0m\x1b[38;5;232m\x1b[48;5;231mK\x1b[0m\x1b[38;5;231m\x1b[48;5;232mB\x1b[0m\x1b[38;5;232m\x1b[48;5;231mN\x1b[0m\x1b[38;5;231m\x1b[48;5;232mR\x1b[0m 8")
print("7 \x1b[38;5;231m\x1b[48;5;232mP\x1b[0m\x1b[38;5;232m\x1b[48;5;231mP\x1b[0m\x1b[38;5;231m\x1b[48;5;232mP\x1b[0m\x1b[38;5;232m\x1b[48;5;231mP\x1b[0m\x1b[38;5;231m\x1b[48;5;232mP\x1b[0m\x1b[38;5;232m\x1b[48;5;231mP\x1b[0m\x1b[38;5;231m\x1b[48;5;232mP\x1b[0m\x1b[38;5;232m\x1b[48;5;231mP\x1b[0m 7")
print("6 \x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m 6")
print("5 \x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m 5")
print("4 \x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m 4")
print("3 \x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m\x1b[38;5;231m\x1b[48;5;232m \x1b[0m\x1b[38;5;232m\x1b[48;5;231m \x1b[0m 3")
print("2 \x1b[38;5;232m\x1b[48;5;231mP\x1b[0m\x1b[38;5;231m\x1b[48;5;232mP\x1b[0m\x1b[38;5;232m\x1b[48;5;231mP\x1b[0m\x1b[38;5;231m\x1b[48;5;232mP\x1b[0m\x1b[38;5;232m\x1b[48;5;231mP\x1b[0m\x1b[38;5;231m\x1b[48;5;232mP\x1b[0m\x1b[38;5;232m\x1b[48;5;231mP\x1b[0m\x1b[38;5;231m\x1b[48;5;232mP\x1b[0m 2")
print("1 \x1b[38;5;231m\x1b[48;5;232mR\x1b[0m\x1b[38;5;232m\x1b[48;5;231mN\x1b[0m\x1b[38;5;231m\x1b[48;5;232mB\x1b[0m\x1b[38;5;232m\x1b[48;5;231mQ\x1b[0m\x1b[38;5;231m\x1b[48;5;232mK\x1b[0m\x1b[38;5;232m\x1b[48;5;231mB\x1b[0m\x1b[38;5;231m\x1b[48;5;232mN\x1b[0m\x1b[38;5;232m\x1b[48;5;231mR\x1b[0m 1")
print("  abcdefgh  ")

Run python3 again:

chess1

Now, it looks nicer but our code became unreadable. How to make it better with help of variables we will cover in the next article.

Congratulations with your first program on Python 3.5!

 

Arrays and objects in ARM Templates

Please, review the article about ARM templates before : Authoring Azure Resource Manager templates.

Before thinking about Nested templates that is possible to imagine a lightweight scenario based on standard ARM template capabilities. Types of variables and parameters in ARM template are not only scalars and they can represent objects and arrays.

Template parameters can take as an input object, array, and secureObject. Variables are type agnostic. Grace to JSON, syntax for those types using is mainly defined by JavaScript Objects and Arrays.

Continue reading “Arrays and objects in ARM Templates”

Test your PowerShell DSC configuration on Azure VM

Troubleshooting and debugging PowerShell DSC configurations could be sometimes very painful. If you are preparing your DSC configuration to use in Azure or even on-premises, you would like to test it in the real environment.

Continue reading “Test your PowerShell DSC configuration on Azure VM”

How to transfer resources between subscriptions in Microsoft Azure?

With Global Availability of Azure Ibiza portal we have got some update on feature request from Feedback Forums, see Move services between subscriptions. Unfortunately I do not have the full list of services and resources which support this feature, Everyday product teams of Microsoft add new ones to the list. Today, you can try it with Azure VM, Azure Automation, Azure Storage, Azure Cache, Azure Search, Azure Batch, Azure DocumentDB, HDInsight.

Change subsription feature of Azure Portal

There are might be few situations when you need it:

  • You have to change contract or create an other subscription
  • You want to transfer some resources to your client from your Sandbox subscription (like in my case it can be a MSDN Developer access) and you do not want or cannot use the ARM Templates.
  • Some other cases? Put it in comments, please.

AMQP Filter for Azure Event Hubs with Apache Qpid Proton

There is no a lot of documentation and examples how to deal with AMQP filters by using qpid-proton (Proton C API).

Deffierent approaches for working with Azure Event Hub are well described by the following link: Using Amqp.Net Lite with Azure Service Bus Event Hubs.

In my practice I’m using qpid-proton 0.8. To set the filter for retriving messages from Event Hub by timestamp offsset:

pn_messenger_t *m_messenger = pn_messenger(NULL);

// ...

// About addresses and filters for Azure Event Hubs: 
// https://amqpnetlite.codeplex.com/wikipage?title=Using%20Amqp.Net%20Lite%20with%20Azure%20Server%20Bus%20Event%20Hub&referringTitle=Documentation
char address[] = "amqps://user:password@host:port/path";
char filter_section[] = "apache.org:selector-filter:string";
// timestamp in milliseconds
char filter_value[] = "amqp.annotation.x-opt-enqueuedtimeutc >= '1422627183000'";

// ...

pn_subscription_t *subsribtion = pn_messenger_subscribe(m_messenger, address);

// get a link and the source endpoint (terminus)
pn_link_t 	*link = pn_messenger_get_link(m_messenger, address, false);
pn_terminus_t	*link_source = pn_link_source(link);
pn_data_t	*link_source_filter_data = pn_terminus_filter(link_source);

pn_data_put_map(link_source_filter_data);
  // add a filter entry
  pn_data_enter(link_source_filter_data);
  // symbol key
  pn_data_put_symbol(link_source_filter_data, pn_bytes(strlen(filter_section), filter_section));
  // described value
  pn_data_put_described(link_source_filter_data);
    pn_data_enter(link_source_filter_data);
    pn_data_put_symbol(link_source_filter_data, pn_bytes(strlen(filter_section), filter_section));
    // filter expression as a string
    pn_data_put_string(link_source_filter_data, pn_bytes(strlen(filter_value), filter_value));
  pn_data_exit(link_source_filter_data);

pn_messenger_start(m_messenger);
	
// ... 
	
// here we'll receive only messages with annotation.x-opt-enqueuedtimeutc >= '1422627183000'
pn_messenger_recv(m_messenger, MESSAGES_COUNT);
	
// ...

You can get binaries of qpid-proton 0.8 as NuGet package which are compiled for processors with IA32 instructions set (I need it for my Intel Galileo Gen2 projects).